Shows how to use xtd::threading::thread class.
#include <xtd/threading/thread>
#include <xtd/console>
#include <xtd/startup>
 
 
class thread_example {
public:
  
  
  
  static void thread_proc() {
    for (auto i = 0; i < 10; ++i) {
      console::write_line("thread_proc: {0}", i);
      
      thread::sleep(0);
    }
  }
  
  static void main() {
    console::write_line("Main thread: Start a second thread.");
    
    
    
    auto t = 
thread {thread_proc};
 
    
    
    
    
    
    t.start();
    
    
    for (auto i = 0; i < 4; ++i) {
      console::write_line("Main thread: Do some work.");
      thread::sleep(0);
    }
    
    console::write_line("Main thread: Call join(), to wait until thread_proc ends.");
    t.join();
    console::write_line("Main thread: thread_proc.join has returned.  Press Enter to end program.");
    console::read_line();
  }
};
 
 
Creates and controls a thread, sets its priority, and gets its status.
Definition thread.hpp:43
 
#define startup_(main_method)
Defines the entry point to be called when the application loads. Generally this is set either to the ...
Definition startup.hpp:175
 
The xtd::threading namespace provides classes and interfaces that enable multithreaded programming....
Definition abandoned_mutex_exception.hpp:11
 
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10