Here you can find the source of lock()
static boolean lock()
//package com.java2s; //License from project: Open Source License import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; public class Main { private static final Lock lock = new ReentrantLock(); private static boolean locked = false; static boolean lock() { lock.lock();/*from www. ja v a2s.com*/ locked = true; return locked; } }