Code example for Future

Methods: get, isCancelled, isDone

0
   } 
 
   public void testAsyncPutAll() throws Exception { 
      Future<Void> f2 = c.putAllAsync(Collections.singletonMap("k", "v3"));
      assert f2 != null;
      assert !f2.isCancelled();
      assert f2.get() == null;
      assert f2.isDone();
      assert c.get("k").equals("v3");
   } 
 
 
   public void testAsyncPutIfAbsent() throws Exception { 
      Future<Void> f2 = c.putAllAsync(Collections.singletonMap("k", "v3"));
      assert f2.get() == null;
      assert f2.isDone();
      assert c.get("k").equals("v3");
      Future f = c.putIfAbsentAsync("k", "v4");
      assert f != null;
      assert !f.isCancelled();
      assert "v3".equals(f.get()) : "Obtained " + f.get();