Exemple #1
0
  @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);
  }
Exemple #2
0
 @Test
 public void set() {
   LongRef ref = new LongRef(10);
   long old = ref.set(100);
   assertEquals(10, old);
   assertEquals(100, ref.get());
 }
Exemple #3
0
  @Test
  public void testHashCode() {
    LongRef ref = new LongRef(10);
    assertEquals(10, ref.hashCode());

    ref.set(200);
    assertEquals(200, ref.hashCode());
  }
Exemple #4
0
 @Override
 public void doRun() throws Exception {
   sleepMs(300);
   txInt.set(value);
 }