threads.cpp 350 B

12345678910111213141516171819202122232425262728293031
  1. #include "Thread.h"
  2. #include "Log.h"
  3. #include <unistd.h>
  4. using namespace crown;
  5. int32_t first_function(void* ft)
  6. {
  7. Thread* thread = (Thread*)ft;
  8. while(thread->is_running())
  9. {
  10. Log::i("I'm in the first thread");
  11. }
  12. return 0;
  13. }
  14. int main()
  15. {
  16. Thread ft("first-thread");
  17. ft.start(first_function, &ft);
  18. sleep(2);
  19. ft.stop();
  20. return 0;
  21. }