Home | History | Annotate | Download | only in lang

Lines Matching defs:thread

27 public class OldThreadGroupTest extends TestCase implements Thread.UncaughtExceptionHandler {
29 class MyThread extends Thread {
42 Thread.sleep(50);
58 Thread.yield();
70 // A thread that runs in initialThreadGroup throughout each test.
78 Thread t1 = new Thread(tg, new Runnable() {
98 ThreadGroup tg = new ThreadGroup("thread suspension");
99 assertTrue("Thread suspention can not be changed",
101 assertTrue("Thread suspention can not be changed",
107 Thread[] listOfThreads = new Thread[numThreads];
111 assertTrue("Initial thread must be in enumeration of threads",
118 Thread[] initialThreads = new Thread[initialThreadCount];
129 for(MyThread thread : newThreads) {
130 thread.start();
132 Thread.sleep(500); // starting threads isn't instant!
134 Set<Thread> initialPlusNew = new HashSet<Thread>();
137 Thread[] afterStartThreads = new Thread[afterStartCount];
139 assertEquals(initialPlusNew, new HashSet<Thread>(Arrays.asList(afterStartThreads)));
143 for(MyThread thread : newThreads) {
144 thread.interrupt();
146 Thread.sleep(500); // killing threads isn't instant
148 Thread[] afterDeathThreads = new Thread[afterDeathCount];
233 assertEquals(Thread.currentThread().getThreadGroup(), new ThreadGroup("test").getParent());
243 Thread.setDefaultUncaughtExceptionHandler(this);
245 Thread t1 = new Thread(tg, new Runnable() {
248 Thread.sleep(5000);
254 assertFalse("Incorrect state of thread", interrupted);
256 assertFalse("Incorrect state of thread", interrupted);
262 assertTrue("Incorrect state of thread", interrupted);
281 Thread thread = launchFiveSecondDummyThread(group);
284 Thread.sleep(1000);
296 private Thread launchFiveSecondDummyThread(ThreadGroup group) {
297 Thread thread = new Thread(group, "Bar") {
300 Thread.sleep(5000);
307 thread.start();
309 return thread;
313 * @see java.lang.Thread.UncaughtExceptionHandler#uncaughtException(java.lang.Thread, java.lang.Throwable)
315 public void uncaughtException(Thread t, Throwable e) {
317 Thread.setDefaultUncaughtExceptionHandler(null);
323 initialThreadGroup = new ThreadGroup(Thread.currentThread().getThreadGroup(), "test group");
324 initialThread = new MyThread(initialThreadGroup, "initial thread");
337 for (MyThread thread : myThreads) {
338 thread.interrupt();
341 for (MyThread thread : myThreads) {
342 thread.join(2000);
343 if (thread.isAlive()) {
344 fail("Thread " + thread + " did not die as it should have.");
376 MyThread thread = new MyThread(group, "MyThread " + i + " of " + threadCount);
377 myThreads.add(thread);
378 out.add(thread);