| 68 | 1 package fschmidt.util.executor; | 
|  | 2 | 
|  | 3 import java.util.Date; | 
|  | 4 import java.util.Map; | 
|  | 5 import java.util.Set; | 
|  | 6 import java.util.concurrent.ConcurrentHashMap; | 
|  | 7 import java.util.concurrent.TimeUnit; | 
|  | 8 import java.util.concurrent.BlockingQueue; | 
|  | 9 | 
|  | 10 | 
|  | 11 public final class ThreadTimer implements RunnableWrapper { | 
|  | 12 	private final Map<Thread,Date> map = new ConcurrentHashMap<Thread,Date>(); | 
|  | 13 | 
|  | 14 	@Override public Runnable wrap(final Runnable command) { | 
|  | 15 		return new Runnable(){public void run(){ | 
|  | 16 			map.put(Thread.currentThread(),new Date()); | 
|  | 17 			try { | 
|  | 18 				command.run(); | 
|  | 19 			} finally { | 
|  | 20 				map.remove(Thread.currentThread()); | 
|  | 21 			} | 
|  | 22 		}}; | 
|  | 23 	} | 
|  | 24 | 
|  | 25 	public Date whenRun(Thread thread) { | 
|  | 26 		return map.get(thread); | 
|  | 27 	} | 
|  | 28 | 
|  | 29 	public Set<Thread> getThreads() { | 
|  | 30 		return map.keySet(); | 
|  | 31 	} | 
|  | 32 } |