This week's book giveaway is in the General Computing forum.
We're giving away four copies of Learning Regular Expressions and have Ben Forta on-line!
See this thread for details.
Win a copy of Learning Regular Expressions this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

What is the Linux command to find the created timer daemon  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a ServletListener with which I create a timer object Timer timer = new Timer(timerName, true).
I define a timer task TimerTask task = new TimerTask() { ...};
I schedule the task for repeated fixed rate execution as follows:
timer.scheduleAtFixedRate(task, initialDelay, thePeriod);
and at boot a timer daemon thread is created.

PROBLEM (QUESTION):
How do I determine that the daemon thread is indeed created? Which command do I use to find the created timer, and daemon thread? Where is the information about the timer and the daemon kept?

I'd appreciate your quick reply. Thank you.
 
Java Cowboy
Sheriff
Posts: 16084
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

You have a reference to the Timer object, and also to the TimerTask object.

If you can create the Timer and schedule a TimerTask with it and no exceptions happen, then you know that creating the timer thread succeeded.

What do you mean by "Linux command"? Are you looking for some Linux shell command to check if the timer thread exists? The timer thread is a thread inside the JVM of your running program, not something that runs separately from your program. Note that if your program exits, all daemon threads inside your program stop too.

I suspect that you created a program that schedules a timer task and that then exits, and you seem to expect that even after your program has stopped the timer is still running somewhere and the task will run when it is time. That is not the case.
 
Raymond Rugemalira
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply. In fact I have an application on the glassfish application server.

When the application server is started at boot,a ServletContextListener is executed and the context is initialized so that a timer is scheduled for a particular task to be executed repeatedly after a known long period.

I'm assuming the task will be executed repeatedly according to schedule as long as my application server is up and running. Is my assumption correct? This is the first time I use a ServletContextListener to schedule a timer and accompanying task therefore the query. I do appreciate your input. Kindly let me know whether my reasoning is correct.


Jesper de Jong wrote:Welcome to the Ranch.

You have a reference to the Timer object, and also to the TimerTask object.

If you can create the Timer and schedule a TimerTask with it and no exceptions happen, then you know that creating the timer thread succeeded.

What do you mean by "Linux command"? Are you looking for some Linux shell command to check if the timer thread exists? The timer thread is a thread inside the JVM of your running program, not something that runs separately from your program. Note that if your program exits, all daemon threads inside your program stop too.

I suspect that you created a program that schedules a timer task and that then exits, and you seem to expect that even after your program has stopped the timer is still running somewhere and the task will run when it is time. That is not the case.

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!