[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Small vm/reference Thread.join() hack
From: |
Mark Wielaard |
Subject: |
Small vm/reference Thread.join() hack |
Date: |
Mon, 25 Aug 2003 23:34:37 +0200 |
Hi,
Although I think we should move quickly to the new Thread/VMThread setup
I needed Thread.join(long) to work reliably on kissme. So I made the
following quick hack that work for me.
* vm/reference/java/lang/Thread.java (join(long)): Call sleep(10),
not sleep(1). Explicitly check elapsed time.
Without this, one of the new mauve tests hangs forever. And
Thread.join() was very resource intensive since it was continuously
sleeping 1 milisecond.
Cheers,
Mark
Index: ChangeLog
===================================================================
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.1408
diff -u -r1.1408 ChangeLog
--- ChangeLog 24 Aug 2003 18:10:55 -0000 1.1408
+++ ChangeLog 25 Aug 2003 21:31:57 -0000
@@ -1,3 +1,8 @@
+2003-08-25 Mark Wielaard <address@hidden>
+
+ * vm/reference/java/lang/Thread.java (join(long)): Call sleep(10),
+ not sleep(1). Explicitly check elapsed time.
+
2003-08-24 Mark Wielaard <address@hidden>
* configure.in (AC_INIT): Use four argument version.
Index: vm/reference/java/lang/Thread.java
===================================================================
RCS file: /cvsroot/classpath/classpath/vm/reference/java/lang/Thread.java,v
retrieving revision 1.27
diff -u -r1.27 Thread.java
--- vm/reference/java/lang/Thread.java 9 Aug 2003 18:30:18 -0000 1.27
+++ vm/reference/java/lang/Thread.java 25 Aug 2003 21:31:58 -0000
@@ -1,5 +1,5 @@
/* Thread -- an independent thread of executable code
- Copyright (C) 1998, 2001, 2002 Free Software Foundation
+ Copyright (C) 1998, 2001, 2002, 2003 Free Software Foundation
This file is part of GNU Classpath.
@@ -688,16 +688,19 @@
Thread current = currentThread();
if (ms == 0 && ns == 0)
while (isAlive())
- current.sleep(1);
+ current.sleep(10);
else
{
- while (--ms >= 0)
+ long startTime = System.currentTimeMillis();
+ long currentTime = startTime;
+ do
{
if (! isAlive())
return;
- current.sleep(1);
+ current.sleep(10);
+ currentTime = System.currentTimeMillis();
}
- current.sleep(0, ns);
+ while (Math.abs(startTime - currentTime) < ms);
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Small vm/reference Thread.join() hack,
Mark Wielaard <=