1 17 package org.apache.excalibur.thread.impl; 18 19 import org.apache.excalibur.thread.ThreadControl; 20 21 28 final class DefaultThreadControl 29 implements ThreadControl 30 { 31 private Thread m_thread; 33 34 private Throwable m_throwable; 36 37 42 protected DefaultThreadControl( final Thread thread ) 43 { 44 m_thread = thread; 45 } 46 47 56 public synchronized void join( final long milliSeconds ) 57 throws IllegalStateException , InterruptedException 58 { 59 if (! isFinished() ) 60 { 61 m_thread.join(milliSeconds); 62 } 63 } 64 65 public void interupt() 66 throws IllegalStateException , SecurityException 67 { 68 interrupt(); 69 } 70 71 77 public synchronized void interrupt() 78 throws IllegalStateException , SecurityException 79 { 80 if( !isFinished() ) 81 { 82 m_thread.interrupt(); 83 } 84 } 85 86 91 public synchronized boolean isFinished() 92 { 93 return ( null == m_thread ); 94 } 95 96 102 public Throwable getThrowable() 103 { 104 return m_throwable; 105 } 106 107 112 protected synchronized void finish( final Throwable throwable ) 113 { 114 m_thread = null; 115 m_throwable = throwable; 116 notifyAll(); 117 } 118 } 119 | Popular Tags |