1 4 package com.tc.util.concurrent; 5 6 import EDU.oswego.cs.dl.util.concurrent.Latch; 7 import EDU.oswego.cs.dl.util.concurrent.SynchronizedRef; 8 9 import com.tc.util.TCTimer; 10 import com.tc.util.TCTimerImpl; 11 12 import java.util.TimerTask ; 13 14 import junit.framework.TestCase; 15 16 public class TCTimerTest extends TestCase { 17 18 public void test() throws InterruptedException { 19 final String name = "testing 1 2 3"; 20 TCTimer timer = new TCTimerImpl(name, true); 21 22 final Latch proceed = new Latch(); 23 final SynchronizedRef actualName = new SynchronizedRef(null); 24 25 TimerTask task = new TimerTask () { 26 public void run() { 27 actualName.set(Thread.currentThread().getName()); 28 proceed.release(); 29 } 30 }; 31 32 timer.schedule(task, 0L); 33 proceed.acquire(); 34 35 assertEquals(name, actualName.get()); 36 37 timer.cancel(); 38 } 39 40 } 41 | Popular Tags |