Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / May 2006

Tip: Looking for answers? Try searching our database.

MIDP Timer taks:

Thread view: 
Alex Hunsley - 24 May 2006 11:49 GMT
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
Domagoj Klepac - 24 May 2006 12:26 GMT
>The documentation for java.util.Timer says the following:
>
[quoted text clipped - 9 lines]
>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

Signature

Ouroboros ltd. - http://www.ouroboros.hr 
Antispam: to reply, remove extra monkey from reply-to address.

Thomas Hawtin - 24 May 2006 12:33 GMT
> The documentation for java.util.Timer says the following:
>
[quoted text clipped - 8 lines]
> 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
Signature

Unemployed English Java programmer
http://jroller.com/page/tackline/



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.