Code example for TimeoutException

0
     */ 
    @Override 
    public final void lock() throws TimeoutException { 
        try { 
            if (!lock.tryLock(30, TimeUnit.SECONDS)) {
                throw new TimeoutException("The attempt to lock the database timed out.");
            } 
        } catch (InterruptedException e) {
            Throwables.propagate(e);
        } 
    } 
 
    /** 
     * Unlocks access to the main repository refs. 
     */ 
    @Override 
    public final void unlock() { 
        lock.unlock();
    } 
 
}