chapter_005/src/main/java/ru/job4j/wait/DeadLock.java
/**
     * 2 threads try to control 2 locks.
     */
2 threads try to control 2 locks.
2 threads try to control 2 locks .
public void start() {
        th1 = new Thread(() -> {
            lock1.lock();
            count.countDown();
            try {
                count.await();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            lock2.lock();
        });
        th2 = new Thread(() -> {
            lock2.lock();
            count.countDown();
            try {
                count.await();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            lock1.lock();
        });
        th1.start();
        th2.start();
    }
public void start ( ) { th1 = new Thread ( ( ) -> { lock1 . lock ( ) ; count . countDown ( ) ; try { count . await ( ) ; } catch ( InterruptedException e ) { e . printStackTrace ( ) ; } lock2 . lock ( ) ; } ) ; th2 = new Thread ( ( ) -> { lock2 . lock ( ) ; count . countDown ( ) ; try { count . await ( ) ; } catch ( InterruptedException e ) { e . printStackTrace ( ) ; } lock1 . lock ( ) ; } ) ; th1 . start ( ) ; th2 . start ( ) ; }
2 threads try to control 2 locks.
2 threads try to control 2 locks .