hotspot/src/os/windows/vm/os_windows.cpp
changeset 23176 d3073ac441cc
parent 22891 1f5d1fff23fa
child 23487 0f7e268cd9e3
equal deleted inserted replaced
23175:892220ab2ae1 23176:d3073ac441cc
  3617 bool os::is_interrupted(Thread* thread, bool clear_interrupted) {
  3617 bool os::is_interrupted(Thread* thread, bool clear_interrupted) {
  3618   assert(!thread->is_Java_thread() || Thread::current() == thread || Threads_lock->owned_by_self(),
  3618   assert(!thread->is_Java_thread() || Thread::current() == thread || Threads_lock->owned_by_self(),
  3619          "possibility of dangling Thread pointer");
  3619          "possibility of dangling Thread pointer");
  3620 
  3620 
  3621   OSThread* osthread = thread->osthread();
  3621   OSThread* osthread = thread->osthread();
  3622   bool interrupted = osthread->interrupted();
       
  3623   // There is no synchronization between the setting of the interrupt
  3622   // There is no synchronization between the setting of the interrupt
  3624   // and it being cleared here. It is critical - see 6535709 - that
  3623   // and it being cleared here. It is critical - see 6535709 - that
  3625   // we only clear the interrupt state, and reset the interrupt event,
  3624   // we only clear the interrupt state, and reset the interrupt event,
  3626   // if we are going to report that we were indeed interrupted - else
  3625   // if we are going to report that we were indeed interrupted - else
  3627   // an interrupt can be "lost", leading to spurious wakeups or lost wakeups
  3626   // an interrupt can be "lost", leading to spurious wakeups or lost wakeups
  3628   // depending on the timing
  3627   // depending on the timing. By checking thread interrupt event to see
       
  3628   // if the thread gets real interrupt thus prevent spurious wakeup.
       
  3629   bool interrupted = osthread->interrupted() && (WaitForSingleObject(osthread->interrupt_event(), 0) == WAIT_OBJECT_0);
  3629   if (interrupted && clear_interrupted) {
  3630   if (interrupted && clear_interrupted) {
  3630     osthread->set_interrupted(false);
  3631     osthread->set_interrupted(false);
  3631     ResetEvent(osthread->interrupt_event());
  3632     ResetEvent(osthread->interrupt_event());
  3632   } // Otherwise leave the interrupted state alone
  3633   } // Otherwise leave the interrupted state alone
  3633 
  3634