Code example for TimeoutException

0
	@Override 
	public V get(long timeout, TimeUnit unit) throws InterruptedException, TimeoutException {
		if (latch.await(timeout, unit)) {
			return ref.get();
		} 
		throw new TimeoutException();
	} 
	 
	public void set(V val) {
		ref.set(val);
		latch.countDown();
	} 
 
}