+ while (! done_sleeping)
+ {
+ if (millis == 0 && nanos == 0)
+ r = pthread_cond_wait (¤t->wait_cond, ¤t->wait_mutex);
+ else
+ r = pthread_cond_timedwait (¤t->wait_cond, ¤t->wait_mutex,
+ &ts);
+
+ // In older glibc's (prior to 2.1.3), the cond_wait functions may
+ // spuriously wake up on a signal. Catch that here.
+ if (r != EINTR)
+ done_sleeping = true;
+ }
+
+ // Check for an interrupt *before* releasing the wait mutex.
+ jboolean interrupted = current_obj->interrupt_flag;
+
+ pthread_mutex_unlock (¤t->wait_mutex);
+
+ // Reaquire the monitor mutex, and restore the lock count.
+ pthread_mutex_lock (&mu->mutex);
+ mu->owner = self;
+ mu->count = count;
+
+ // If we were interrupted, or if a timeout occurred, remove ourself from
+ // the cv wait list now. (If we were notified normally, notify() will have
+ // already taken care of this)
+ if (r == ETIMEDOUT || interrupted)
+ {
+ _Jv_Thread_t *prev = NULL;
+ for (_Jv_Thread_t *t = cv->first; t != NULL; t = t->next)
+ {
+ if (t == current)