Calling thread every 5 mins.

Discussion in 'Java' started by ramakrishna, Jan 10, 2007.

  1. ramakrishna

    ramakrishna Guest

    Hi
    Iam new to threading concepts.
    Can anyone tell how to create a thread and invoke it for every 5mins.

    Thanks InAdvance.
     
    ramakrishna, Jan 10, 2007
    #1
    1. Advertising

  2. ramakrishna

    Hybris Guest

    Il Tue, 09 Jan 2007 21:24:47 -0800, ramakrishna ha scritto:

    > Can anyone tell how to create a thread and invoke it for every 5mins.


    see Timer and TimerTask
     
    Hybris, Jan 10, 2007
    #2
    1. Advertising

  3. ramakrishna

    Berlin Brown Guest

    ramakrishna wrote:
    > Hi
    > Iam new to threading concepts.
    > Can anyone tell how to create a thread and invoke it for every 5mins.
    >
    > Thanks InAdvance.


    A threaded way, say if you want to do anything more complex is to
    implement the Runnable interface and then start a Thread, ie:

    public class TestThreadWrites implements Runnable {

    public void run() {
    runningFlag = true;
    while(runningFlag) {

    try {
    Thread.sleep(5 * 60 *1000);
    } catch (InterruptedException e) {
    e.printStackTrace();
    }

    }

    }


    }

    ....
    ....
    ....
    Runnable runnable = new TestThreadWrites(logger);
    Thread thread = new Thread(runnable);
    thread.start();


    Bot Berlin
    http://www.botspiritcompany.com/botlist
     
    Berlin Brown, Jan 10, 2007
    #3
    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. Funky
    Replies:
    3
    Views:
    492
    Steven Cheng[MSFT]
    Oct 12, 2005
  2. Manjesh Gowda
    Replies:
    2
    Views:
    395
    Howard
    Sep 2, 2004
  3. switzerland qunatium computer

    HERE I BUILT A QUICK MATRIX TOOOK 5 MINS

    switzerland qunatium computer, Jul 28, 2006, in forum: Java
    Replies:
    1
    Views:
    348
    Andrew Thompson
    Jul 28, 2006
  4. switzerland qunatium computer

    HERE I BUILT A QUICK MATRIX TOOOK 5 MINS

    switzerland qunatium computer, Jul 28, 2006, in forum: Python
    Replies:
    6
    Views:
    299
    Diez B. Roggisch
    Jul 29, 2006
  5. switzerland qunatium computer

    HERE I BUILT A QUICK MATRIX TOOOK 5 MINS

    switzerland qunatium computer, Jul 28, 2006, in forum: C Programming
    Replies:
    0
    Views:
    225
    switzerland qunatium computer
    Jul 28, 2006
Loading...

Share This Page