Discussion:
how to make a thread sleep forever
Alex Flint
2010-05-06 14:55:52 UTC
Permalink
Is there an elegant way to make the current thread go to sleep forever? I
simply want the current thread to sleep indefinitely, i.e. until a call to
exit() or similar. Obviously I could call sleep() in a loop, or I could
create an artificial deadlock, but I was wondering if there is a more
elegant way?

Cheers,
Alex
Eric J. Holtman
2010-05-06 15:10:32 UTC
Permalink
Post by Alex Flint
Is there an elegant way to make the current thread go to sleep
forever? I simply want the current thread to sleep indefinitely, i.e.
until a call to exit() or similar. Obviously I could call sleep() in a
loop, or I could create an artificial deadlock, but I was wondering if
there is a more elegant way?
Why can't you just exit the thread?
Ovanes Markarian
2010-05-06 15:13:41 UTC
Permalink
Hi!
what about locking a mutex and wait on this mutex from the thread. This is
also what you call artificial deadlock, but anyway. Another possiblity to
wait on an event which never occurs. E.g.

lock the mutex from the thread and use a condition variable which is never
signaled. I am just curios: why do you need such a thread at all?


Regards,
Ovanes
Post by Alex Flint
Is there an elegant way to make the current thread go to sleep forever? I
simply want the current thread to sleep indefinitely, i.e. until a call to
exit() or similar. Obviously I could call sleep() in a loop, or I could
create an artificial deadlock, but I was wondering if there is a more
elegant way?
Cheers,
Alex
_______________________________________________
Boost-users mailing list
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Loading...