Questions tagged [spurious-wakeup]
19 questions
0
votes
1 answer
POSIX condition variables VS Win32 Event Objects (about spurious wakeup problem)
In POSIX, because of "spurious wakeup" problem, programmers are forced to use while() instead of if when checking condition.
I think spurious wakeup is unintuitive and confusing problem, but I thought it's an inevitable problem.
Recently, I found…

Salieri
- 73
- 8
0
votes
1 answer
What will be the behavior of a while loop that encloses pthread_cond_wait?
I would like to know what happens with the while after a waiting thread is waked.
To avoid 'spurious wake-ups', the pthreads documentation points out that you need to use pthread_cond_wait inside a while statement.
So, when the pthread_cond_wait is…

Shinforinpola
- 200
- 1
- 15
0
votes
1 answer
Java: Does this pause the thread correctly?
I am curious whether it is possible to pause a thread t in Java and allow another thread to resume it later, by having t run the following pause code:
while(true) {
try {
synchronized(t) {
t.wait();
}
} catch(InterruptedException…

user21820
- 569
- 8
- 17
0
votes
2 answers
Thread safe queues and spurious wakes
I am currently reading a book about multi threading in C++. In one chapter I found some source code for a thread safe queue. It is roughly built like this:
template
class QueueThreadSafe
{
private:
std::mutex m_mutex;
…

Brotcrunsher
- 1,964
- 10
- 32