0

I know some trick with condition, but it is not helpful.

Suppose that I have infinite loop in my thread function. How can I suspend only this thread, not all process?

Oleksandr Shtykhno
  • 766
  • 2
  • 7
  • 12

1 Answers1

1

Use std::condition_variable or std::this_thread::sleep_for

Denis Ermolin
  • 5,530
  • 6
  • 27
  • 44
  • 1
    aren't these things only in C++11? (question is tagged c++) – saeedn Oct 24 '12 at 14:57
  • 1
    @saeedn: and what's the current C++ standard, given that this year is 2012? ;-) – Steve Jessop Oct 24 '12 at 15:35
  • @SteveJessop, its not too much to ask for the equivalent in c++, considering perhaps the OP cant use c++11 and the question is tagged posix. The Posix type is `pthread_cond_t`, here is a related question http://stackoverflow.com/q/1136371/1158895 – Brady Oct 24 '12 at 16:30
  • 2
    He can use boost for portability – Denis Ermolin Oct 24 '12 at 17:59