User Tools

Site Tools


c:c_threads:create_background_tasks

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
c:c_threads:create_background_tasks [2021/03/05 11:04] – created peterc:c_threads:create_background_tasks [2021/03/05 16:40] (current) peter
Line 1: Line 1:
 ====== C - C++ Threads - Create Background Tasks ====== ====== C - C++ Threads - Create Background Tasks ======
  
-You can make a std::thread run in the background by calling std::thread::detach() on it.+You can make a std::thread run in the background by calling **std::thread::detach()** on it.
  
   * Once detached, a thread continues to run in the background and cannot be communicated with or waited upon to complete.   * Once detached, a thread continues to run in the background and cannot be communicated with or waited upon to complete.
Line 30: Line 30:
 } }
 </code> </code>
 +
 +<WRAP info>
 +**NOTE:**  The 10 millisecond sleep is needed otherwise no output will be displayed.
 +
 +The reason for this is that the main thread terminates before the "Count" thread has had an opportunity to run.
 +
 +</WRAP>
 +
 +
 +
 +
  
c/c_threads/create_background_tasks.1614942262.txt.gz · Last modified: 2021/03/05 11:04 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki