Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > MIDP Timer taks:

Reply
Thread Tools

MIDP Timer taks:

 
 
Alex Hunsley
Guest
Posts: n/a
 
      05-24-2006
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
 
Reply With Quote
 
 
 
 
Domagoj Klepac
Guest
Posts: n/a
 
      05-24-2006
On Wed, 24 May 2006 11:49:39 +0100, Alex Hunsley
<(E-Mail Removed)> 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.
 
Reply With Quote
 
 
 
 
Thomas Hawtin
Guest
Posts: n/a
 
      05-24-2006
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/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
page timer, or redirect timer Simon ASP .Net 1 11-04-2005 07:14 PM
java.lang.NullPointerException at com.sun.kvem.midp.MIDP.run(MIDP.java:651) Fahad Java 1 08-08-2005 02:11 PM
Will application J2ME MIDP 2.0 based of one device run another J2ME MIDP 2.0 device? nishadixit Java 5 06-01-2005 05:40 AM
System.Timers.Timer/System.Threading.Timer Not Firing At All on Dev Server james.e.coleman@gmail.com ASP .Net 1 02-22-2005 09:41 PM
System.Timers.Timer vs. System.Threading.Timer Kelsang Wangchuk ASP .Net 0 07-31-2003 04:28 PM



Advertisments