diff options
Diffstat (limited to 'libjava')
-rw-r--r-- | libjava/ChangeLog | 20 | ||||
-rw-r--r-- | libjava/testsuite/libjava.lang/TLtest.java | 2 | ||||
-rw-r--r-- | libjava/testsuite/libjava.lang/Thread_Alive.java | 3 | ||||
-rw-r--r-- | libjava/testsuite/libjava.lang/Thread_HoldsLock.java | 4 | ||||
-rw-r--r-- | libjava/testsuite/libjava.lang/Thread_Interrupt.java | 63 | ||||
-rw-r--r-- | libjava/testsuite/libjava.lang/Thread_Join.java | 1 | ||||
-rw-r--r-- | libjava/testsuite/libjava.lang/Thread_Monitor.java | 1 | ||||
-rw-r--r-- | libjava/testsuite/libjava.lang/Thread_Sleep.java | 5 | ||||
-rw-r--r-- | libjava/testsuite/libjava.lang/Thread_Wait.java | 1 | ||||
-rw-r--r-- | libjava/testsuite/libjava.lang/Thread_Wait_2.java | 1 | ||||
-rw-r--r-- | libjava/testsuite/libjava.lang/Thread_Wait_Interrupt.java | 1 | ||||
-rw-r--r-- | libjava/testsuite/libjava.lang/pr179.java | 2 |
12 files changed, 58 insertions, 46 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 2ad34fa..09ef462 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,5 +1,25 @@ 2004-07-27 Bryce McKinlay <mckinlay@redhat.com> + * testsuite/libjava.lang/TLtest.java: Reduce sleep time. + * testsuite/libjava.lang/Thread_Alive.java: Remove old email address. + Reduce sleep time. + * testsuite/libjava.lang/Thread_HoldsLock.java: Modify to work around + compiler bug. + * testsuite/libjava.lang/Thread_Interrupt.java: Remove old email + address. Reduce sleep times. Synchronize with target threads before + attempting to interrupt them. Don't try to calibrate yeild count, + instead, always loop for a fixed time. + * testsuite/libjava.lang/Thread_Join.java: Remove old email address. + * testsuite/libjava.lang/Thread_Monitor.java: Likewise. + * testsuite/libjava.lang/Thread_Wait.java: Likewise. + * testsuite/libjava.lang/Thread_Wait_2.java: Likewise. + * testsuite/libjava.lang/Thread_Wait_Interrupt.java: Likewise. + * testsuite/libjava.lang/pr179.java: Likewise. + * testsuite/libjava.lang/Thread_Sleep.java: Likewise. Reduce sleep + time. Remove upper bounds check on sleep time. + +2004-07-27 Bryce McKinlay <mckinlay@redhat.com> + * testsuite/libjava.lang/Thread_HoldsLock.java: New test case. * testsuite/libjava.lang/Thread_HoldsLock.out: New. diff --git a/libjava/testsuite/libjava.lang/TLtest.java b/libjava/testsuite/libjava.lang/TLtest.java index b7f4115..6ddd0cb 100644 --- a/libjava/testsuite/libjava.lang/TLtest.java +++ b/libjava/testsuite/libjava.lang/TLtest.java @@ -46,7 +46,7 @@ class ThreadTest extends Thread { d.set (Integer.toString (value)); try { - sleep((int)(Math.random() * 500)); + sleep((int)((Math.random() * 20))); } catch (InterruptedException e) {} } diff --git a/libjava/testsuite/libjava.lang/Thread_Alive.java b/libjava/testsuite/libjava.lang/Thread_Alive.java index d97ea25c..e885e16 100644 --- a/libjava/testsuite/libjava.lang/Thread_Alive.java +++ b/libjava/testsuite/libjava.lang/Thread_Alive.java @@ -1,6 +1,5 @@ // Test the status of the isAlive() flag before, during, and after thread // execution. Check that thread's threadgroup is null after thread exits. -// Origin: Bryce McKinlay <bryce@albatross.co.nz> public class Thread_Alive implements Runnable { @@ -12,7 +11,7 @@ public class Thread_Alive implements Runnable t.start(); System.out.println(t.isAlive()); - Thread.sleep(100); + Thread.sleep(50); synchronized (ta) { diff --git a/libjava/testsuite/libjava.lang/Thread_HoldsLock.java b/libjava/testsuite/libjava.lang/Thread_HoldsLock.java index 3a46466..62119a1 100644 --- a/libjava/testsuite/libjava.lang/Thread_HoldsLock.java +++ b/libjava/testsuite/libjava.lang/Thread_HoldsLock.java @@ -20,8 +20,8 @@ public class Thread_HoldsLock public void check() { - boolean held = Thread.currentThread().holdsLock(lock); - System.out.println(held); + Thread this_thread = Thread.currentThread(); + System.out.println(this_thread.holdsLock(lock)); } } diff --git a/libjava/testsuite/libjava.lang/Thread_Interrupt.java b/libjava/testsuite/libjava.lang/Thread_Interrupt.java index cb569c8..a692474 100644 --- a/libjava/testsuite/libjava.lang/Thread_Interrupt.java +++ b/libjava/testsuite/libjava.lang/Thread_Interrupt.java @@ -1,11 +1,21 @@ // Test interrupt() behaviour on a thread in wait(), sleep(), and spinning // in a loop. -// Origin: Bryce McKinlay <bryce@albatross.co.nz> -class Waiter extends Thread +class ThreadBase extends Thread +{ + boolean ready = false; + + synchronized void ready() + { + ready = true; + } +} + +class Waiter extends ThreadBase { public synchronized void run() { + super.ready(); System.out.println ("wait()"); try { @@ -22,14 +32,15 @@ class Waiter extends Thread } } -class Sleeper extends Thread +class Sleeper extends ThreadBase { public void run() { + super.ready(); System.out.println ("sleep()"); try { - sleep(2000); + sleep(5000); System.out.println("Error: sleep() completed normally."); } catch (InterruptedException x) @@ -42,40 +53,23 @@ class Sleeper extends Thread } } -class Looper extends Thread +class Looper extends ThreadBase { - // Return the number of Thread.yield()s we can do in 500ms. - static long calibrate () - { - long i = 1; - - for (int tries = 0; tries < 40; tries++) - { - long t = System.currentTimeMillis(); - for (long n = 0; n < i; n++) - Thread.yield(); - long t_prime = System.currentTimeMillis(); - if (t_prime - t > 500) - return i; - i *= 2; - } - // We have no system clock. Give up. - throw new RuntimeException ("We have no system clock."); - } - - static long yields = calibrate (); - public void run() { + super.ready(); System.out.println ("Busy waiting"); int count = 0; - for (long i=0; i < yields; i++) + long start = System.currentTimeMillis(); + while (true) { Thread.yield(); - count += 5; if (isInterrupted ()) break; + long now = System.currentTimeMillis(); + if ((now - start) > 5000) + break; } synchronized (this) { @@ -91,10 +85,11 @@ class Looper extends Thread } } -class Joiner extends Thread +class Joiner extends ThreadBase { public void run() { + super.ready(); System.out.println("join()"); try { @@ -133,11 +128,17 @@ public class Thread_Interrupt sleep_and_interrupt (j); } - public static void sleep_and_interrupt(Thread t) + public static void sleep_and_interrupt(ThreadBase t) { try { - Thread.sleep (250); + synchronized (t) + { + while (!t.ready) + t.wait(10); + } + + Thread.sleep (50); t.interrupt (); long t1 = System.currentTimeMillis(); t.join (5000); diff --git a/libjava/testsuite/libjava.lang/Thread_Join.java b/libjava/testsuite/libjava.lang/Thread_Join.java index 711b05c..9f7f2fb 100644 --- a/libjava/testsuite/libjava.lang/Thread_Join.java +++ b/libjava/testsuite/libjava.lang/Thread_Join.java @@ -1,5 +1,4 @@ // Many threads join a single thread. -// Origin: Bryce McKinlay <bryce@albatross.co.nz> class Sleeper implements Runnable { diff --git a/libjava/testsuite/libjava.lang/Thread_Monitor.java b/libjava/testsuite/libjava.lang/Thread_Monitor.java index f1ffa67..649a75c 100644 --- a/libjava/testsuite/libjava.lang/Thread_Monitor.java +++ b/libjava/testsuite/libjava.lang/Thread_Monitor.java @@ -1,5 +1,4 @@ // Test that monitor locks work and are recursive. -// Origin: Bryce McKinlay <bryce@albatross.co.nz> class T implements Runnable { diff --git a/libjava/testsuite/libjava.lang/Thread_Sleep.java b/libjava/testsuite/libjava.lang/Thread_Sleep.java index e7f4a81..7220a6a 100644 --- a/libjava/testsuite/libjava.lang/Thread_Sleep.java +++ b/libjava/testsuite/libjava.lang/Thread_Sleep.java @@ -1,5 +1,4 @@ // Test that Thread.sleep() works. -// Origin: Bryce McKinlay <bryce@albatross.co.nz> public class Thread_Sleep { @@ -9,9 +8,9 @@ public class Thread_Sleep { long start = System.currentTimeMillis(); System.out.println("sleeping"); - Thread.sleep(1000); + Thread.sleep(50); long end = System.currentTimeMillis(); - if ((end - start) > 1100 || (end - start) < 990) + if ((end - start) < 50) System.out.println ("failed"); else System.out.println("ok"); diff --git a/libjava/testsuite/libjava.lang/Thread_Wait.java b/libjava/testsuite/libjava.lang/Thread_Wait.java index a649282..8850824 100644 --- a/libjava/testsuite/libjava.lang/Thread_Wait.java +++ b/libjava/testsuite/libjava.lang/Thread_Wait.java @@ -1,5 +1,4 @@ // Test basic thread creation and wait/notify functionality. -// Origin: Bryce McKinlay <bryce@albatross.co.nz> public class Thread_Wait implements Runnable { diff --git a/libjava/testsuite/libjava.lang/Thread_Wait_2.java b/libjava/testsuite/libjava.lang/Thread_Wait_2.java index a03cb94..7ee5172 100644 --- a/libjava/testsuite/libjava.lang/Thread_Wait_2.java +++ b/libjava/testsuite/libjava.lang/Thread_Wait_2.java @@ -1,6 +1,5 @@ // Create many threads waiting on a monitor. Interrupt some of them. Do the // others wake up correctly with notify() and/or notifyAll()? -// Origin: Bryce McKinlay <bryce@albatross.co.nz> import java.util.Vector; diff --git a/libjava/testsuite/libjava.lang/Thread_Wait_Interrupt.java b/libjava/testsuite/libjava.lang/Thread_Wait_Interrupt.java index be7b555..609527c 100644 --- a/libjava/testsuite/libjava.lang/Thread_Wait_Interrupt.java +++ b/libjava/testsuite/libjava.lang/Thread_Wait_Interrupt.java @@ -1,6 +1,5 @@ // Create two threads waiting on a monitor. Interrupt one of them. Does the // other wake up correctly? -// Origin: Bryce McKinlay <bryce@albatross.co.nz> class Waiter extends Thread { diff --git a/libjava/testsuite/libjava.lang/pr179.java b/libjava/testsuite/libjava.lang/pr179.java index ec99efc..7124ded 100644 --- a/libjava/testsuite/libjava.lang/pr179.java +++ b/libjava/testsuite/libjava.lang/pr179.java @@ -4,8 +4,6 @@ // Class.isInstance() and Class.isAssignableFrom(), and isAssignableFrom() // functionality in the event that an interface argument that is not // implemented by any loaded class is given. -// -// Bryce McKinlay <bryce@albatross.co.nz> class A { |