MIDP Timer taks:

Discussion in 'Java' started by Alex Hunsley, May 24, 2006.

  1. Alex Hunsley

    Alex Hunsley Guest

    The documentation for java.util.Timer says the following:

    "However, this can take arbitrarily long to occur. By default, the task
    execution thread does not run as a daemon thread, so it is capable of
    keeping an application from terminating."

    (thes are the MIDP api docs, but I think it's the same in the regular
    edition)

    I want the task execution thread to executre as a daemon thread, but
    there's no way I can see of doing this, despite the hint in the docs
    above that it is possible (i.e it says "by default...")
    Any ideas?
    thanks,
    lex
     
    Alex Hunsley, May 24, 2006
    #1
    1. Advertising

  2. On Wed, 24 May 2006 11:49:39 +0100, Alex Hunsley
    <> wrote:
    >The documentation for java.util.Timer says the following:
    >
    >"However, this can take arbitrarily long to occur. By default, the task
    >execution thread does not run as a daemon thread, so it is capable of
    >keeping an application from terminating."
    >
    >(thes are the MIDP api docs, but I think it's the same in the regular
    >edition)
    >
    >I want the task execution thread to executre as a daemon thread, but
    >there's no way I can see of doing this, despite the hint in the docs
    >above that it is possible (i.e it says "by default...")
    >Any ideas?


    "After the last live reference to a Timer object goes away and all
    outstanding tasks have completed execution, the timer's task execution
    thread terminates gracefully (and becomes subject to garbage
    collection)."

    That means that timer execution task will keep your application from
    terminating only if it is currently executing one of your tasks. If
    tasks are pending, but are not yet executed, the timer execution
    thread _will_ terminate gracefully.

    So if you keep your timer tasks short, you have nothing to worry -
    actually, it's pretty nice that timer execution thread is not a daemon
    thread. That means that your tasks are not abruptly stopped if
    application shuts down when they're executed, possibly leaving your
    tasks in unstable state.

    Domchi

    --
    Ouroboros ltd. - http://www.ouroboros.hr
    Antispam: to reply, remove extra monkey from reply-to address.
     
    Domagoj Klepac, May 24, 2006
    #2
    1. Advertising

  3. Alex Hunsley wrote:
    > The documentation for java.util.Timer says the following:
    >
    > "However, this can take arbitrarily long to occur. By default, the task
    > execution thread does not run as a daemon thread, so it is capable of
    > keeping an application from terminating."
    >
    > (thes are the MIDP api docs, but I think it's the same in the regular
    > edition)
    >
    > I want the task execution thread to executre as a daemon thread, but
    > there's no way I can see of doing this, despite the hint in the docs
    > above that it is possible (i.e it says "by default...")


    MIDP/CLDC doesn't yet appear to support daemon threads, so Timer has no
    chance. You should call cancel on the Timer instead. A bit C++, but you
    can't have everything done for you.

    Presumably implementations use some sort of native implementation for
    Timer. Under Java SE, a finaliser (evil) kills off timer threads of
    unreachable timers. CLDC has neither finalisers nor reference queues.

    Tom Hawtin
    --
    Unemployed English Java programmer
    http://jroller.com/page/tackline/
     
    Thomas Hawtin, May 24, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kelsang Wangchuk

    System.Timers.Timer vs. System.Threading.Timer

    Kelsang Wangchuk, Jul 31, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    730
    Kelsang Wangchuk
    Jul 31, 2003
  2. Replies:
    1
    Views:
    1,640
    Steve C. Orr [MVP, MCSD]
    Feb 22, 2005
  3. Simon

    page timer, or redirect timer

    Simon, Nov 4, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    11,233
    Bruce Barker
    Nov 4, 2005
  4. nishadixit
    Replies:
    5
    Views:
    1,275
    Joe Discar
    Jun 1, 2005
  5. Fahad
    Replies:
    1
    Views:
    598
    Andrew Thompson
    Aug 8, 2005
Loading...

Share This Page