public void first() { try { ThreadUtils.sleep(5000); System.out.println("first"); sem1.release(); } catch (Exception e) { e.printStackTrace(); } }
public void third() { try { sem2.acquire(); sem2.release(); ThreadUtils.sleep(1000); System.out.println("third"); } catch (Exception e) { e.printStackTrace(); } }
public void second() { try { sem1.acquire(); // since the CF alreay holds the sem1, this has to be wait sem1.release(); ThreadUtils.sleep(3000); System.out.println("second"); sem2.release(); } catch (Exception e) { e.printStackTrace(); } }