SMF For Free Support Forum
Signup For Free Forum
July 05, 2008, 06:41:46 pm *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Welcome to SMF For Free. The best free SMF Host
 
   Home   Help Search Arcade Gallery Login Register  

Pages: [1]
  Print  
Author Topic: java multithreading ... Explaining  (Read 439 times)
0 Members and 1 Guest are viewing this topic.
zilchuary
SMF For Free Newbie
*
Offline Offline

Posts: 11


View Profile
« 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:
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()
Logged
LaundryLady
Global Moderator
*
Offline Offline

Posts: 2773


Keep Smiling, Let'em Wonder!


View Profile WWW
« Reply #1 on: January 27, 2008, 02:04:37 pm »

Please use pms for private chat, Thanks,

LL
Logged



Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.5 | SMF © 2006-2008, Simple Machines LLC
ServerBeach Coupon
Page created in 0.418 seconds with 17 queries.