search

Home  >  Q&A  >  body text

c++11 - c++ 线程detach 问题?

高洛峰高洛峰2803 days ago690

reply all(2)I'll reply

  • 高洛峰

    高洛峰2017-04-17 13:07:39

    Because you are not waiting for all threads to finish. The simplest and crudest method is to create 10 threads and save them all, and then have a loop to join them one by one, and finally detach.

    If you can use the Windows API, use this (https://msdn.microsoft.com/en-us/library/windows/desktop/ms687028(v=vs.85).aspx).

    reply
    0
  • 高洛峰

    高洛峰2017-04-17 13:07:39

    The program just closed when 5 were printed out

    reply
    0
  • Cancelreply