List all existing timer tasks

Discussion in 'Java' started by Deepa, Mar 22, 2006.

  1. Deepa

    Deepa Guest

    Hi,

    I am new to this group, I have a urgent query.
    I will appreciate if someone can help me on this

    I need to design a generic timer task tool.

    Is there any JDK API through which I can list out all the timer task
    running in the application?

    Timer task are nothing but the threads, which are running through a
    scheduler servlet.

    Thanks in advance.

    Deepa
    Deepa, Mar 22, 2006
    #1
    1. Advertising

  2. Deepa

    Roedy Green Guest

    On 21 Mar 2006 20:02:57 -0800, "Deepa" <>
    wrote, quoted or indirectly quoted someone who said :

    >Is there any JDK API through which I can list out all the timer task
    >running in the application?


    You would need to example the source for the two flavours of timer to
    see if that is possible. See http://mindprod.com/jgloss/timer.html

    In general, in Java it is difficult to add instrumentation to a system
    class.
    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Java custom programming, consulting and coaching.
    Roedy Green, Mar 22, 2006
    #2
    1. Advertising

  3. Deepa

    Deepa Guest

    Thats fine but I really want to see the list of all timer task which
    are running in my application.

    How can I get that list.
    Deepa, Mar 22, 2006
    #3
  4. Deepa

    Chris Smith Guest

    Deepa <> wrote:
    > Thats fine but I really want to see the list of all timer task which
    > are running in my application.


    Roedy gave the best answer you're going to get, which is that there's no
    good way to do that. If you don't like the answer, too bad. It's still
    true.

    If you desperately need this, then perhaps you could accomplish your
    task with JVMTI, which would allow you to intercept all calls to methods
    of java.util.Timer or javax.swing.Timer and keep a list of the tasks.
    You may (or may not -- I really don't know) be able to do the same by
    rigging an AOP implementation to do runtime instrumentation of the
    bootclasspath and do the same thing that way. Or, if you're willing to
    depend on implementation details of the standard API, then do as Roedy
    said and look at the source code to these two classes... and then use
    reflection with setAccessible(true) to examine the private members and
    get the list of tasks.

    None of those are good things to do, though. They might work for a
    development tool (though the latter two are poor even for that purpose),
    but won't be very good choices at all in production code. To solve that
    problem, you'd need to be willing to step back and consider other
    solutions besides getting a list of all timer tasks in the system. WHY
    do you think that you need to do that, and what other mechanisms might
    be available to reach the same goal?

    --
    www.designacourse.com
    The Easiest Way To Train Anyone... Anywhere.

    Chris Smith - Lead Software Developer/Technical Trainer
    MindIQ Corporation
    Chris Smith, Mar 22, 2006
    #4
  5. Deepa

    Deepa Guest

    I will explain you in detail

    We need to develop a admin tool for timer tasks
    which will List all existing timer tasks with information ( current
    state, last time run, next scheduled to, start and stop options).

    so the tasks which are running how can I get the list...
    Deepa, Mar 22, 2006
    #5
  6. Deepa

    jlowery05 Guest

    If you have access to the code, wrap the class and instrument the
    wrapper with the information you need.

    Other than that, it appears you're stuck.
    jlowery05, Mar 22, 2006
    #6
  7. Deepa schrieb:

    > We need to develop a admin tool for timer tasks
    > which will List all existing timer tasks with information ( current
    > state, last time run, next scheduled to, start and stop options).


    Take a look at the JMX-API (java management extension). You can write a
    MBean to administer your timer tasks. With the right interface methods you
    will be able to start, stop and list timer tasks.

    The timer task itself I would place into a simple list, that is a member of
    your MBean.

    The implementation part would not exceed a few days. If you are experienced
    with java and MBeans it will be only one or two days.

    If you are looking for a ready to use framework, have a look at quartz at

    http://www.opensymphony.com/quartz

    Kind regards,

    Frank.

    --
    Geld allein macht nicht gl├╝cklich.
    Es kommt auch auf die Menge an...
    Frank Seidinger, Mar 22, 2006
    #7
  8. Deepa

    Chris Smith Guest

    Deepa <> wrote:
    > We need to develop a admin tool for timer tasks
    > which will List all existing timer tasks with information ( current
    > state, last time run, next scheduled to, start and stop options).
    >
    > so the tasks which are running how can I get the list...


    Are you acually reading the responses people write? It doesn't seem
    like it. I spent a good paragraph listing three different ways to do
    it. (Frank just added a fourth, which I haven't verified.)

    --
    www.designacourse.com
    The Easiest Way To Train Anyone... Anywhere.

    Chris Smith - Lead Software Developer/Technical Trainer
    MindIQ Corporation
    Chris Smith, Mar 22, 2006
    #8
  9. Deepa

    Deepa Guest

    Hey Chris, I am reading all the responses.
    Deepa, Mar 22, 2006
    #9
  10. Deepa

    Oliver Wong Guest

    "Deepa" <> wrote in message
    news:...
    > Hey Chris, I am reading all the responses.
    >


    I was pretty sure there was a "How to ask smart questions" entry on
    this, but I couldn't find it, so I'm gonna paraphrase the answer off the top
    of my head here:

    Explain why the previous responces did not satisfy your question.

    - Oliver
    Oliver Wong, Mar 22, 2006
    #10
  11. Deepa

    Roedy Green Guest

    On 22 Mar 2006 05:01:40 -0800, "Deepa" <>
    wrote, quoted or indirectly quoted someone who said :

    >Hey Chris, I am reading all the responses.


    You got my back up dismissing my answer as if I had not responded. If
    you dismiss an answer and want a different one, you pretty well have
    to explain why the offered approach is not feasible for your case or
    asking for more elaboration if that is the problem.

    You came across like some precious princess stamping her foot
    demanding someone find her strawberries in the snow served on a golden
    plate.
    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Java custom programming, consulting and coaching.
    Roedy Green, Mar 22, 2006
    #11
  12. Deepa

    Deepa Guest

    Hey I discussed with my client they didn't wnt the JMX thing...they
    want it to do in a simple manner just using some of the APIs. I will
    explore more and will get back to u on this.
    Deepa, Mar 23, 2006
    #12
  13. Deepa

    Deepa Guest

    Hey I discussed with my client they don't wnt the JMX thing...they want
    it to do in a simple manner just using some of the APIs. I will explore
    more and will get back to u on this.
    Deepa, Mar 23, 2006
    #13
    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:
    699
    Kelsang Wangchuk
    Jul 31, 2003
  2. Replies:
    1
    Views:
    1,563
    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,166
    Bruce Barker
    Nov 4, 2005
  4. Replies:
    0
    Views:
    786
  5. Replies:
    8
    Views:
    465
    Jorgen Grahn
    Jul 15, 2013
Loading...

Share This Page