• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
WOApplication's TimeoutTask inner class question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

WOApplication's TimeoutTask inner class question


  • Subject: WOApplication's TimeoutTask inner class question
  • From: Bogdan Zlatanov <email@hidden>
  • Date: Thu, 30 Apr 2009 18:49:22 +0300

    
 Hello everybody,

   I've been JAD-ing around WOSession and WOApplication out of curiousity and bumped into this inner for WOApplication class:


    protected class TimeoutTask extends TimerTask {

        protected TimeoutTask() {
            super();
        }

        public void start() {
            applicationTimer().schedule(this, (long)(timeOut() * 1000D));
        }

        public void run() {
            long inactivity = System.currentTimeMillis() - WOApplication._TheLastApplicationAccessTime;
            if((double)inactivity >= timeOut())
                terminate();
            else
                applicationTimer().schedule(this, (long)(timeOut() * 1000D) - inactivity); (*)
        }

        public boolean cancel() {
            return super.cancel();
        }
    }


  Looking at the (*) bolded line in the else block I couldn't help spotting that an attempt to reuse both the timer, which is usually OK, and the TimerTask? Now, this shouldn't be possible according to the JDK docs, so I've tried it and of course got the expected 

"Exception in thread "Timer-0" java.lang.IllegalStateException: Task already scheduled or cancelled"

error. 

   Another thing is the checked condition in the if statement - comparing milliseconds to seconds, since inactivity holds the milliseconds since last application access time, and timeOut() returns the time out in seconds, which is kind of explaining why the else block is usually skipped.

   It might be a very stupid and obvious thing, but I'd appreciate if anyone can explain to me why (*) would work for WO and not for me?



   Cheers,
   Bogdan 
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: WOApplication's TimeoutTask inner class question
      • From: Chuck Hill <email@hidden>
  • Prev by Date: Re: MOSXSWebPassword
  • Next by Date: Re: WWDC sold out, WOWODC hotel booking for weekend or streaming?
  • Previous by thread: Re: Webobjects-dev Digest, Vol 6, Issue 402
  • Next by thread: Re: WOApplication's TimeoutTask inner class question
  • Index(es):
    • Date
    • Thread