reuse a thread which is no longer "alive"

Discussion in 'Java' started by sayoyo, Feb 25, 2004.

  1. sayoyo

    sayoyo Guest

    Hi,

    Is there some way that we can reuse a thread by replacing the runnable
    object of the thread? like a thread is not "alive" anymore, then we remove
    the runnable object(is it possible????) and then run it again.

    Thanks you very much

    Sayoyo
     
    sayoyo, Feb 25, 2004
    #1
    1. Advertising

  2. sayoyo wrote:

    > Is there some way that we can reuse a thread by replacing the runnable
    > object of the thread? like a thread is not "alive" anymore, then we remove
    > the runnable object(is it possible????) and then run it again.


    Not on that level, no.

    But it's not all that difficult to write a class that takes a Runnable,
    executes its run() method and then waits to recieve a new Runnable instead
    of finishing its own run() method. This is known as a thread pool:
    http://www-106.ibm.com/developerworks/java/library/j-jtp0730.html
     
    Michael Borgwardt, Feb 25, 2004
    #2
    1. Advertising

  3. sayoyo

    sayoyo Guest

    Thanks you very much:)

    sayoyo


    "Michael Borgwardt" <> a écrit dans le message de
    news:c1ihk7$1iv7p5$-berlin.de...
    > sayoyo wrote:
    >
    > > Is there some way that we can reuse a thread by replacing the runnable
    > > object of the thread? like a thread is not "alive" anymore, then we

    remove
    > > the runnable object(is it possible????) and then run it again.

    >
    > Not on that level, no.
    >
    > But it's not all that difficult to write a class that takes a Runnable,
    > executes its run() method and then waits to recieve a new Runnable instead
    > of finishing its own run() method. This is known as a thread pool:
    > http://www-106.ibm.com/developerworks/java/library/j-jtp0730.html
    >
     
    sayoyo, Feb 26, 2004
    #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. tshad
    Replies:
    5
    Views:
    564
    Steve C. Orr [MVP, MCSD]
    May 17, 2005
  2. Hylander

    To reuse or not to reuse....

    Hylander, Feb 26, 2004, in forum: Java
    Replies:
    0
    Views:
    442
    Hylander
    Feb 26, 2004
  3. code reuse and design reuse

    , Feb 7, 2006, in forum: C Programming
    Replies:
    16
    Views:
    1,067
    Malcolm
    Feb 12, 2006
  4. jacob navia

    To reuse or not to reuse

    jacob navia, Nov 5, 2006, in forum: C Programming
    Replies:
    19
    Views:
    571
    Dave Thompson
    Dec 18, 2006
  5. hisan
    Replies:
    1
    Views:
    1,422
    Dan Stromberg
    Jun 25, 2012
Loading...

Share This Page