Patch: FYI: PR libgcj/22211 -vs- 4.0.x
Tom Tromey
tromey@redhat.com
Tue Sep 6 23:49:00 GMT 2005
I'm checking this in on the 4.0 branch. This fixes PR libgcj/22211;
it already was committed to the trunk, but the commit to the branch
was delayed as the branch was frozen at that point.
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
PR libgcj/22211:
* 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.
Index: java/lang/Thread.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/Thread.java,v
retrieving revision 1.35
diff -u -r1.35 Thread.java
--- java/lang/Thread.java 13 Jan 2005 20:26:38 -0000 1.35
+++ java/lang/Thread.java 6 Sep 2005 23:10:28 -0000
@@ -16,8 +16,8 @@
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -550,7 +550,7 @@
*
* @return whether this Thread is alive
*/
- public final boolean isAlive()
+ public final synchronized boolean isAlive()
{
return alive_flag;
}
Index: java/lang/natThread.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/natThread.cc,v
retrieving revision 1.30
diff -u -r1.30 natThread.cc
--- java/lang/natThread.cc 14 Jan 2005 07:36:27 -0000 1.30
+++ java/lang/natThread.cc 6 Sep 2005 23:10:28 -0000
@@ -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 @@
{
checkAccess ();
natThread *nt = (natThread *) data;
- _Jv_ThreadInterrupt (nt->thread);
+ JvSynchronize sync (this);
+ if (alive_flag)
+ _Jv_ThreadInterrupt (nt->thread);
}
void
@@ -215,7 +217,12 @@
// 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 @@
jint
_Jv_AttachCurrentThread(java::lang::Thread* thread)
{
+ JvSynchronize sync (thread);
if (thread == NULL || thread->startable_flag == false)
return -1;
thread->startable_flag = false;
More information about the Java-patches
mailing list