• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

What is the Linux command to find the created timer daemon

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic