2 Replies Latest reply on Mar 17, 2002 11:21 PM by Guy Rouillier

    Odd timer behavior

    Guy Rouillier Newbie

      I've been playing around with the timer, using the example from the docs as a starting point. In the notification listener (same EJB as the one that adds the notifications), I added a 15 second sleep to see what would happen (simulating a long running process). I have two notifications added: 1 is on a 10 second cycle, and 2 is on a 4 second cycle. Without the sleep, everything works as expected. With the sleep, here is what I'm seeing:

      01:35:32,781] 1
      01:35:47,781] 2
      01:36:06,781] 2
      01:36:21,781] 1
      01:36:40,781] 2
      01:36:55,781] 1
      01:37:14,781] 2
      01:37:29,781] 1
      01:37:48,781] 2
      01:38:03,781] 1
      01:38:22,781] 2
      01:38:37,781] 1
      01:38:56,781] 2
      01:39:11,781] 1
      01:39:30,781] 2
      01:39:45,781] 1
      01:40:04,781] 2
      01:40:19,781] 1
      01:40:38,781] 2
      01:40:53,781] 1

      Notice that 1 runs immediately after the 15-second sleep is over, as I expected. But 2 consistently runs 4 seconds after the sleep is over. For 2, it looks like the clock doesn't start ticking until the sleep finishes. Any ideas why this would work like this?

        • 1. Re: Odd timer behavior
          Adrian Brock Master

          Can you post your code.

          Looks to me like you've got some synchronization
          between the two notifications? Both look like they are
          on a 34 sec cycle.

          Regards,
          Adrian

          • 2. Re: Odd timer behavior
            Guy Rouillier Newbie

            The synchronization is in the timer itself. It serializes all events, and only executes one at a time. My handler consists of two statements:

            print
            sleep 15 seconds

            So event 1 prints and sleeps for 15 seconds, then event 2 **should** print and sleep for 15 seconds. So you should see a periodicity of 30 seconds. But what you are seeing, and what was my original question, is that when event 1 finishes sleeping, event 2 waits an additional 4 seconds before it prints. The repeat time for event 2 is 4 seconds, but that should have been absorbed when event 1 was sleeping. That is how event 1 is working; you'll notice that event 1 always prints immediately after event 2 has finished sleeping for 15 seconds; event 1 does NOT wait its repeat time, which is 10 seconds. So how come event 2 waits?