3295 bool os::is_interrupted(Thread* thread, bool clear_interrupted) { |
3295 bool os::is_interrupted(Thread* thread, bool clear_interrupted) { |
3296 assert(!thread->is_Java_thread() || Thread::current() == thread || Threads_lock->owned_by_self(), |
3296 assert(!thread->is_Java_thread() || Thread::current() == thread || Threads_lock->owned_by_self(), |
3297 "possibility of dangling Thread pointer"); |
3297 "possibility of dangling Thread pointer"); |
3298 |
3298 |
3299 OSThread* osthread = thread->osthread(); |
3299 OSThread* osthread = thread->osthread(); |
3300 bool interrupted; |
3300 bool interrupted = osthread->interrupted(); |
3301 interrupted = osthread->interrupted(); |
3301 // There is no synchronization between the setting of the interrupt |
3302 if (clear_interrupted == true) { |
3302 // and it being cleared here. It is critical - see 6535709 - that |
|
3303 // we only clear the interrupt state, and reset the interrupt event, |
|
3304 // if we are going to report that we were indeed interrupted - else |
|
3305 // an interrupt can be "lost", leading to spurious wakeups or lost wakeups |
|
3306 // depending on the timing |
|
3307 if (interrupted && clear_interrupted) { |
3303 osthread->set_interrupted(false); |
3308 osthread->set_interrupted(false); |
3304 ResetEvent(osthread->interrupt_event()); |
3309 ResetEvent(osthread->interrupt_event()); |
3305 } // Otherwise leave the interrupted state alone |
3310 } // Otherwise leave the interrupted state alone |
3306 |
3311 |
3307 return interrupted; |
3312 return interrupted; |