aboutsummaryrefslogtreecommitdiff
path: root/libjava/java/lang
diff options
context:
space:
mode:
authorBryce McKinlay <bryce@albatross.co.nz>1999-12-24 01:00:46 +0000
committerBryce McKinlay <bryce@gcc.gnu.org>1999-12-24 01:00:46 +0000
commit43cbc9430d557a3219ff833751c38132f831036e (patch)
tree42d8776b8882e3c389088fa07c0348d511ab5edf /libjava/java/lang
parent07875628ee1bbcc753b44b4d962779d577cd605a (diff)
downloadgcc-43cbc9430d557a3219ff833751c38132f831036e.zip
gcc-43cbc9430d557a3219ff833751c38132f831036e.tar.gz
gcc-43cbc9430d557a3219ff833751c38132f831036e.tar.bz2
natObject.cc (notify): Throw message with IllegalMonitorStateException.
1999-12-22 Bryce McKinlay <bryce@albatross.co.nz> * java/lang/natObject.cc (notify): Throw message with IllegalMonitorStateException. (notifyAll): Ditto. (wait): Ditto. * java/lang/Thread.java (isInterrupted): Don't clear interrupt_flag. (isInterrupted_): New function, which does clear interrupt_flag. (interrupt): Use `isInterrupted_'. * java/lang/natThread.cc (interrupt): Add comment. (join): Set `Prev' in joiner loop. Change various calls to `isInterrupted' to use `isInterrupted_'. * posix-threads.cc (_Jv_CondWait): Allways use pthread_cond_timedwait on linux. Set result to 0 on an interrupt. Test interrupted status of java Thread object directly. FLAG_INTERRUPTED: removed. (_Jv_ThreadStart): Throw OutOfMemoryError if pthread_create fails. (_Jv_ThreadInterrupt): Don't set FLAG_INTERRUPTED. (_Jv_InitThreads): Don't block SIGINT. (_Jv_ThreadWait): Don't configure SIGINT handler. From-SVN: r31082
Diffstat (limited to 'libjava/java/lang')
-rw-r--r--libjava/java/lang/natObject.cc9
-rw-r--r--libjava/java/lang/natThread.cc16
2 files changed, 16 insertions, 9 deletions
diff --git a/libjava/java/lang/natObject.cc b/libjava/java/lang/natObject.cc
index 0ca5a58..3d9f9fb 100644
--- a/libjava/java/lang/natObject.cc
+++ b/libjava/java/lang/natObject.cc
@@ -175,7 +175,8 @@ java::lang::Object::notify (void)
sync_init ();
_Jv_SyncInfo *si = (_Jv_SyncInfo *) sync_info;
if (_Jv_CondNotify (&si->condition, &si->mutex))
- JvThrow (new IllegalMonitorStateException);
+ JvThrow (new IllegalMonitorStateException(JvNewStringLatin1
+ ("current thread not owner")));
}
void
@@ -185,7 +186,8 @@ java::lang::Object::notifyAll (void)
sync_init ();
_Jv_SyncInfo *si = (_Jv_SyncInfo *) sync_info;
if (_Jv_CondNotifyAll (&si->condition, &si->mutex))
- JvThrow (new IllegalMonitorStateException);
+ JvThrow (new IllegalMonitorStateException(JvNewStringLatin1
+ ("current thread not owner")));
}
void
@@ -197,7 +199,8 @@ java::lang::Object::wait (jlong timeout, jint nanos)
JvThrow (new IllegalArgumentException);
_Jv_SyncInfo *si = (_Jv_SyncInfo *) sync_info;
if (_Jv_CondWait (&si->condition, &si->mutex, timeout, nanos))
- JvThrow (new IllegalMonitorStateException);
+ JvThrow (new IllegalMonitorStateException(JvNewStringLatin1
+ ("current thread not owner")));
if (Thread::interrupted())
JvThrow (new InterruptedException);
}
diff --git a/libjava/java/lang/natThread.cc b/libjava/java/lang/natThread.cc
index 4f04363..8239f17 100644
--- a/libjava/java/lang/natThread.cc
+++ b/libjava/java/lang/natThread.cc
@@ -130,10 +130,13 @@ java::lang::Thread::interrupt (void)
// another thread to exit.
natThread *nt = (natThread *) data;
_Jv_MutexLock (&nt->interrupt_mutex);
+ // Notify the interrupt condition to interrupt sleep() and join() calls.
_Jv_CondNotify (&nt->interrupt_cond, &nt->interrupt_mutex);
- _Jv_MutexUnlock (&nt->interrupt_mutex);
-
+ // Send a signal to the target thread to interrupt system calls. On Linux,
+ // this will also interrupt the target thread from *any* _Jv_CondWait call,
+ // ie wait(). This behaviour is not portable, however.
_Jv_ThreadInterrupt (nt->thread);
+ _Jv_MutexUnlock (&nt->interrupt_mutex);
}
void
@@ -145,7 +148,7 @@ java::lang::Thread::join (jlong millis, jint nanos)
_Jv_Throw (new IllegalArgumentException);
Thread *current = currentThread ();
- if (current->isInterrupted ())
+ if (current->isInterrupted_ ())
_Jv_Throw (new InterruptedException);
// Update the list of all threads waiting for this thread to exit.
@@ -199,11 +202,12 @@ java::lang::Thread::join (jlong millis, jint nanos)
t->next = 0;
break;
}
+ prev = t;
}
JvAssert (t != NULL);
_Jv_MonitorExit (this);
- if (current->isInterrupted ())
+ if (current->isInterrupted_ ())
_Jv_Throw (new InterruptedException);
}
@@ -240,7 +244,7 @@ java::lang::Thread::sleep (jlong millis, jint nanos)
++nanos;
Thread *current = currentThread ();
- if (current->isInterrupted ())
+ if (current->isInterrupted_ ())
_Jv_Throw (new InterruptedException);
// We use a condition variable to implement sleeping so that an
@@ -253,7 +257,7 @@ java::lang::Thread::sleep (jlong millis, jint nanos)
millis, nanos);
}
- if (current->isInterrupted ())
+ if (current->isInterrupted_ ())
_Jv_Throw (new InterruptedException);
}