[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [AJUG] Threads?

If you want the thread to run again after stopping it you'll have to setup
classes a bit differently.  Instead of extending the Thread class make it
the Runnable interface.  Then in that class place a private Thread member
When you call your helper function, create a new Thread object passing in
the 'this'
pointer and then call the start() method.  E.g.:

public class MyRestartableThread extends Runnable
    private Thread thread = null;

    public void startHerUp()
	thread = new Thread(this);

    public void run()
	// Yadda yadda


	// exit

- Pros

-----Original Message-----
From: D. Michael Nelson [mailto:dmn1@bellsouth.net]
Sent: Sunday, June 17, 2001 8:28 PM
Subject: [AJUG] Threads?

I am confused as to why my thread process is will not process.  I have a
class MyThread that extends the Thread class and implements the run()
method.  In this class, I have a public helper method that calls the start()

I have another class that instantiates an instance of MyThread, and then
calls the instaniated MyThread object Helper method to invoke the execution
of thread.  The thread process generates an exception, which was expected
and desired.  However, when I attempt to invoke the thread again via
theMyThread object Helper method, the thread run() method does not execute.
Any suggestions?

Thanks In Advance,
D. Michael Nelson