SMF For Free Support Forum
Signup For Free Forum
November 23, 2008, 03:58:32 am *
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 744 times)
0 Members and 1 Guest are viewing this topic.
zilchuary
SMF For Free Newbie
*
Offline Offline

Posts: 16


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: 3082


Multi-Tasking Maven


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

Please use pms for private chat, Thanks,

LL
Logged
zilchuary
SMF For Free Newbie
*
Offline Offline

Posts: 16


View Profile
« Reply #2 on: July 09, 2008, 06:15:52 am »

Okay sorry  Cheesy
Logged


Pages: [1]
  Print  
 
Jump to:  

cheap low cost web hosting reviews

Powered by SMF 1.1.7 | SMF © 2006-2008, Simple Machines LLC
ServerBeach Coupon
Page created in 0.35 seconds with 18 queries.