summaryrefslogtreecommitdiff
path: root/libjava
diff options
context:
space:
mode:
authortromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2005-06-29 17:36:16 +0000
committertromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2005-06-29 17:36:16 +0000
commit9c8a72a58a04bd85c6d259b4c68fac92731f940b (patch)
treedf37a657fa3ca4386879af5b0154c15a9a08e524 /libjava
parente313c83f86a56b386390dedacaa0264ce662c8b3 (diff)
downloadgcc-9c8a72a58a04bd85c6d259b4c68fac92731f940b.tar.gz
PR libgcj/22211:
* testsuite/libjava.lang/pr22211.java: New file. * java/lang/natThread.cc (finish_): Synchronize when updating alive_flag. (_Jv_AttachCurrentThread): Likewise. (interrupt): Only call _Jv_ThreadInterrupt if thread is alive. * java/lang/Thread.java (isAlive): Now synchronized. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@101430 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava')
-rw-r--r--libjava/ChangeLog10
-rw-r--r--libjava/java/lang/Thread.java2
-rw-r--r--libjava/java/lang/natThread.cc14
-rw-r--r--libjava/testsuite/libjava.lang/pr22211.java8
4 files changed, 30 insertions, 4 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index 356b3ba0ab7..ba83c06cf2e 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,5 +1,15 @@
2005-06-29 Tom Tromey <tromey@redhat.com>
+ PR libgcj/22211:
+ * testsuite/libjava.lang/pr22211.java: New file.
+ * java/lang/natThread.cc (finish_): Synchronize when updating
+ alive_flag.
+ (_Jv_AttachCurrentThread): Likewise.
+ (interrupt): Only call _Jv_ThreadInterrupt if thread is alive.
+ * java/lang/Thread.java (isAlive): Now synchronized.
+
+2005-06-29 Tom Tromey <tromey@redhat.com>
+
* interpret.cc (run) <insn_checkcast, checkcast_resolved>: Use
_Jv_CheckCast.
diff --git a/libjava/java/lang/Thread.java b/libjava/java/lang/Thread.java
index ef4a3f472f0..b58ff175c02 100644
--- a/libjava/java/lang/Thread.java
+++ b/libjava/java/lang/Thread.java
@@ -550,7 +550,7 @@ public class Thread implements Runnable
*
* @return whether this Thread is alive
*/
- public final boolean isAlive()
+ public final synchronized boolean isAlive()
{
return alive_flag;
}
diff --git a/libjava/java/lang/natThread.cc b/libjava/java/lang/natThread.cc
index e79ab11b9c6..f1064f17c69 100644
--- a/libjava/java/lang/natThread.cc
+++ b/libjava/java/lang/natThread.cc
@@ -1,6 +1,6 @@
// natThread.cc - Native part of Thread class.
-/* Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation
+/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2005 Free Software Foundation
This file is part of libgcj.
@@ -115,7 +115,9 @@ java::lang::Thread::interrupt (void)
{
checkAccess ();
natThread *nt = (natThread *) data;
- _Jv_ThreadInterrupt (nt->thread);
+ JvSynchronize sync (this);
+ if (alive_flag)
+ _Jv_ThreadInterrupt (nt->thread);
}
void
@@ -215,7 +217,12 @@ java::lang::Thread::finish_ ()
// Signal any threads that are waiting to join() us.
_Jv_MutexLock (&nt->join_mutex);
- alive_flag = false;
+
+ {
+ JvSynchronize sync (this);
+ alive_flag = false;
+ }
+
_Jv_CondNotifyAll (&nt->join_cond, &nt->join_mutex);
_Jv_MutexUnlock (&nt->join_mutex);
}
@@ -392,6 +399,7 @@ _Jv_SetCurrentJNIEnv (JNIEnv *env)
jint
_Jv_AttachCurrentThread(java::lang::Thread* thread)
{
+ JvSynchronize sync (thread);
if (thread == NULL || thread->startable_flag == false)
return -1;
thread->startable_flag = false;
diff --git a/libjava/testsuite/libjava.lang/pr22211.java b/libjava/testsuite/libjava.lang/pr22211.java
new file mode 100644
index 00000000000..87a8e555c5d
--- /dev/null
+++ b/libjava/testsuite/libjava.lang/pr22211.java
@@ -0,0 +1,8 @@
+public class pr22211
+{
+ public static void main(String[] args)
+ {
+ Thread x = new Thread();
+ x.interrupt();
+ }
+}