public class MyLockSupport {
public static void main(String[] args) {
Lock lock = new ReentrantLock();
new Thread(()->{
try{
lock.lock();
Thread.sleep(60000);
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
lock.unlock();
}
}, "AA").start();
new Thread(()->{
try{
lock.lock();
Thread.sleep(100000);
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
lock.unlock();
}
}, "BB").start();
new Thread(()->{
try{
lock.lock();
Thread.sleep(100000);
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
lock.unlock();
}
}, "CC").start();
}
}