public static void main(String[] args) { Thread1 thread1 = new Thread1(); Thread thread2 = new Thread(new Thread2()); thread1.start(); thread2.start(); }
public static void main(String[] args) { Runtime.getRuntime().addShutdownHook(new Thread3()); Thread1 t1 = new Thread1(); t1.start(); Thread2 t2 = new Thread2(); t2.start(); }
/** @param args */ public static void main(String[] args) { // TODO Auto-generated method stub CommonStorage CS = new CommonStorage(); Thread1 t1 = new Thread1(CS); try { t1.start(); } catch (Exception e) { e.printStackTrace(); } try { Thread.sleep(2000); System.out.println("Timer ended"); synchronized (t1) { t1.TimerExpired(); t1.notify(); System.out.println("notify() called"); } } catch (Exception e) { e.printStackTrace(); } }