1 17 18 package org.apache.james.util.thread; 19 20 import org.apache.avalon.excalibur.thread.ThreadControl; 21 22 26 final class DefaultThreadControl 27 implements ThreadControl 28 { 29 private Thread m_thread; 31 32 private Throwable m_throwable; 34 35 40 protected DefaultThreadControl( final Thread thread ) 41 { 42 m_thread = thread; 43 } 44 45 54 public synchronized void join( final long milliSeconds ) 55 throws IllegalStateException , InterruptedException 56 { 57 wait( milliSeconds ); 59 70 } 71 72 78 public synchronized void interupt() 79 throws IllegalStateException , SecurityException 80 { 81 if( !isFinished() ) 82 { 83 m_thread.interrupt(); 84 } 85 } 86 87 92 public synchronized boolean isFinished() 93 { 94 return ( null == m_thread ); 95 } 96 97 103 public Throwable getThrowable() 104 { 105 return m_throwable; 106 } 107 108 113 protected synchronized void finish( final Throwable throwable ) 114 { 115 m_thread = null; 116 m_throwable = throwable; 117 notifyAll(); 118 } 119 } 120 | Popular Tags |