1 8 package org.apache.avalon.excalibur.thread.impl; 9 10 import org.apache.avalon.excalibur.thread.ThreadControl; 11 12 17 final class DefaultThreadControl 18 implements ThreadControl 19 { 20 private Thread m_thread; 22 23 private Throwable m_throwable; 25 26 31 protected DefaultThreadControl( final Thread thread ) 32 { 33 m_thread = thread; 34 } 35 36 45 public synchronized void join( final long milliSeconds ) 46 throws IllegalStateException , InterruptedException 47 { 48 wait( milliSeconds ); 50 61 } 62 63 69 public synchronized void interupt() 70 throws IllegalStateException , SecurityException 71 { 72 if( !isFinished() ) 73 { 74 m_thread.interrupt(); 75 } 76 } 77 78 83 public synchronized boolean isFinished() 84 { 85 return ( null == m_thread ); 86 } 87 88 94 public Throwable getThrowable() 95 { 96 return m_throwable; 97 } 98 99 104 protected synchronized void finish( final Throwable throwable ) 105 { 106 m_thread = null; 107 m_throwable = throwable; 108 notifyAll(); 109 } 110 } 111 | Popular Tags |