@Test public void awaitTest() { final LongRef ref = new LongRef(); TestThread t = new TestThread() { @Override public void doRun() throws Exception { ref.await(2); } }; t.start(); sleepMs(500); assertAlive(t); ref.set(1); sleepMs(500); assertAlive(t); ref.set(2); joinAll(t); }
@Test public void set() { LongRef ref = new LongRef(10); long old = ref.set(100); assertEquals(10, old); assertEquals(100, ref.get()); }
@Test public void testHashCode() { LongRef ref = new LongRef(10); assertEquals(10, ref.hashCode()); ref.set(200); assertEquals(200, ref.hashCode()); }
@Override public void doRun() throws Exception { sleepMs(300); txInt.set(value); }