- Timestamp:
- 06/30/13 12:48:20 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
java/main/src/main/java/com/framsticks/util/dispatching/Thread.java
r85 r88 5 5 import java.util.LinkedList; 6 6 import java.util.ListIterator; 7 8 import javax.annotation.OverridingMethodsMustInvokeSuper; 9 10 import com.framsticks.params.annotations.ParamAnnotation; 7 11 import com.framsticks.util.dispatching.RunAt; 8 12 … … 10 14 * @author Piotr Sniegowski 11 15 */ 12 public class Thread<C> implements Dispatcher<C> {16 public class Thread<C> extends AbstractJoinable implements Dispatcher<C> { 13 17 14 18 private static final Logger log = Logger.getLogger(Thread.class.getName()); … … 27 31 } 28 32 29 public Thread(String s) { 30 this(); 31 thread.setName(s); 32 // thread.start(); 33 @OverridingMethodsMustInvokeSuper 34 protected void firstTask() { 33 35 } 34 36 35 public Thread( String s,java.lang.Thread thread) {37 public Thread(java.lang.Thread thread) { 36 38 this.thread = thread; 37 thread.setName(s);38 39 } 39 40 40 public Thread<C> start() { 41 @Override 42 protected void joinableStart() { 41 43 thread.start(); 42 return this;43 44 } 44 45 … … 49 50 50 51 protected void routine() { 52 log.debug("starting thread " + this); 53 firstTask(); 51 54 while (!java.lang.Thread.interrupted()) { 52 55 Task<? extends C> task; … … 76 79 } catch (Exception e) { 77 80 log.error("error in thread: " + e); 78 e.printStackTrace();79 81 } 80 82 } 83 log.debug("finishing thread " + this); 84 finish(); 81 85 } 82 86 … … 124 128 } 125 129 126 public void interrupt() { 130 @Override 131 protected void joinableInterrupt() { 127 132 thread.interrupt(); 128 133 } 129 134 130 public void join() throws InterruptedException { 131 thread.join(); 135 @Override 136 protected void joinableJoin() throws InterruptedException { 137 thread.join(500); 138 log.debug("joined " + this); 132 139 } 133 140 141 @ParamAnnotation 134 142 public void setName(String name) { 135 143 thread.setName(name); 144 } 136 145 146 @ParamAnnotation 147 public String getName() { 148 return thread.getName(); 137 149 } 138 150 … … 140 152 return java.lang.Thread.interrupted(); 141 153 } 154 155 @Override 156 public String toString() { 157 return getName(); 158 } 159 160 @Override 161 protected void joinableFinish() { 162 } 163 142 164 }
Note: See TracChangeset
for help on using the changeset viewer.