package threaddemo;

import java.util.concurrent.locks.LockSupport;

public class ThreadStateWithLockSupport {

    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(LockSupport::park);
        t1.start();
        Thread.sleep(0);
        System.out.println(STR."1.\{t1.getState()}");
        LockSupport.unpark(t1);
        Thread.sleep(0);
        t1.join();
        System.out.println(STR."2.\{t1.getState()}");

        Object o = new Object();
        Thread t2 = new Thread(() -> {
            synchronized (o) {
                try {
                    System.out.println("waiting");
                    o.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });

        t2.start();
        Thread.sleep(10);
        synchronized (o) {
            System.out.println(STR."t2.1.\{t2.getState()}");
            o.notify();
        }
        Thread.sleep(0);
        System.out.println(STR."t2.2.\{t2.getState()}");
    }
}
