SMF For Free Support Forum

General Stuff => Programming => Java => Topic started by: zilchuary on January 04, 2008, 01:25:54 pm

Title: java multithreading ... Explaining
Post 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:


Code: [Select]
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()
Title: Re: java multithreading ... Explaining
Post by: LaundryLady on January 27, 2008, 02:04:37 pm
Please use pms for private chat, Thanks,

LL
Title: Re: java multithreading ... Explaining
Post by: zilchuary on July 09, 2008, 06:15:52 am
Okay sorry  :D