#include <xtd/threading/thread>
#include <xtd/console>
#include <xtd/startup>
#include <thread>
 
 
namespace mixing_std_and_xtd_threads_example {
  class mixing_std_and_xtd_threads_class {
  private:
    }
    
  public:
    static auto main() {
      console::write_line("threads {");
      thread::current_thread().name("main");
      console::write_line(to_string(thread::current_thread()));
      
        thread::sleep(20_ms);
        console::write_line(to_string(t1));
      }};
      t1.name("xtd_thread_1");
      t1.priority(thread_priority::below_normal);
      t1.start();
      
      std::thread t2 {[] {
        thread::current_thread().name("std_thread_2");
        thread::current_thread().priority(thread_priority::highest);
        console::write_line(to_string(thread::current_thread()));
      }};
      
        console::write_line(to_string(thread::current_thread()));
      }};
      t3.name("xtd_thread_3");
      t3.is_background(true);
      t3.start();
      
      std::thread t4 {[] {
        thread::sleep(10_ms);
        thread::current_thread().name("std_thread_4");
        thread::current_thread().priority(thread_priority::highest);
        console::write_line(to_string(thread::current_thread()));
      }};
      
      if (t1.joinable()) t1.join();
      if (t2.joinable()) t2.join();
      if (t3.joinable()) t3.join();
      if (t4.joinable()) t4.join();
      console::write_line("}");
    }
  };
}
 
startup_(mixing_std_and_xtd_threads_example::mixing_std_and_xtd_threads_class::main);
 
 
Creates and controls a thread, sets its priority, and gets its status.
Definition thread.hpp:43
 
xtd::threading::thread_priority priority() const noexcept
Gets a value indicating the scheduling priority of a thread.
 
intptr thread_id() const noexcept
Gets the native operating system thread id.
 
string name() const noexcept
Gets the name of the thread.
 
int32 managed_thread_id() const noexcept
Gets a unique identifier for the current managed thread.
 
xtd::threading::thread_state thread_state() const noexcept
Gets a value containing the states of the current thread.
 
#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