SMF For Free Support Forum
General Stuff => Programming => Java => Topic started by: zilchuary on January 04, 2008, 01:25:54 pm
-
Let's say, for example, RunnableImpl is the class that implements Runnable.
This class defines the void run() method of course, which is the method that will be invoked in a seperate thread.
To launch a new Thread of RunnableImpl:
RunnableImpl impl = new RunnableImpl(); // Simply declaring a new instance of RunnableImpl
Thread t = new Thread(impl); // The Thread class takes either a Thread child or a Runnable implementation
t.start(); // This will fire RunnableImpl.run() in a seperate thread.
Note that run(); will not be reinvoked, if you want it to live past the first invocation you must put a while() loop in to prevent the code exiting run()
-
Please use pms for private chat, Thanks,
LL
-
Okay sorry :D