4 Replies Latest reply on Nov 3, 2002 6:04 PM by Joel Vogt

    Thread in message bean

    conan Newbie

      Hope someone can help me with this, I have no idea what I'm doing. Anyway I'm working on jboss 2.4.3, win2k, jdk1.3.1, tomcat 4. I've created a Queue message bean and in the onMessage method I call the wait3minute() method which wait 3 minutes and then does an operation. here is the code

      public void onMessage(Message message) {
        doStuff.......
        wait3min(message);
      }

      public static Object sync_obj;

      public static void wait3min(BidAsk bidAsk) {
        sync_obj = bidAsk;
        Thread t = new Thread(new Runnable() {
         public void run() {
          System.out.println("Notifier-Thread: waiting for 4000ms");
          try {
          Thread.sleep(1000*60*4);
         } catch (InterruptedException e) {
        }
        System.out.println("Notifier-Thread: again up to work");
        synchronized (sync_obj) {
         System.out.println("Notifier-Thread: execute to notify");
         sync_obj.notifyAll();
        }
         System.out.println("Notifier-Thread: it's over now");
        }
        });
         synchronized (sync_obj) {
          System.out.println("main: start thread and wait for notify");
          t.start();
          try {
           sync_obj.wait();
          } catch (InterruptedException e) {
         }
        }
         System.out.println("main: notify received --> and bye ...");
        }

      If anyone know what to do, please let me know