Ejemplo n.º 1
0
  public static void main(String[] args) {
    Thread1 thread1 = new Thread1();
    Thread thread2 = new Thread(new Thread2());

    thread1.start();
    thread2.start();
  }
Ejemplo n.º 2
0
 public static void main(String[] args) {
   Runtime.getRuntime().addShutdownHook(new Thread3());
   Thread1 t1 = new Thread1();
   t1.start();
   Thread2 t2 = new Thread2();
   t2.start();
 }
Ejemplo n.º 3
0
  /** @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();
    }
  }