TLtest.java: Reduce sleep time.

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.

From-SVN: r85248
This commit is contained in:
Bryce McKinlay 2004-07-28 02:44:06 +00:00 committed by Bryce McKinlay
parent 1a837f7746
commit ce961468b7
12 changed files with 58 additions and 46 deletions

View File

@ -1,3 +1,23 @@
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.

View File

@ -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) {}
}

View File

@ -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)
{

View File

@ -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));
}
}

View File

@ -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);

View File

@ -1,5 +1,4 @@
// Many threads join a single thread.
// Origin: Bryce McKinlay <bryce@albatross.co.nz>
class Sleeper implements Runnable
{

View File

@ -1,5 +1,4 @@
// Test that monitor locks work and are recursive.
// Origin: Bryce McKinlay <bryce@albatross.co.nz>
class T implements Runnable
{

View File

@ -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");

View File

@ -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
{

View File

@ -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;

View File

@ -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
{

View File

@ -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
{