Advertise Here

Author Topic: java multithreading ... Explaining  (Read 7362 times)

0 Members and 1 Guest are viewing this topic.

Offline zilchuary

  • SMF For Free Newbie
  • *
  • Posts: 16
    • View Profile

  • Total Badges: 10
    Badges: (View All)
    Topic Starter Combination Level 2 Level 1 10 Posts
java multithreading ... Explaining
« 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()

Offline LaundryLady

  • Helpers
  • *
  • Posts: 3253
  • Internet Challenged
    • View Profile

  • Total Badges: 26
    Badges: (View All)
    Seventh year Anniversary Sixth year Anniversary Search Poll Voter Level 5
Re: java multithreading ... Explaining
« Reply #1 on: January 27, 2008, 02:04:37 pm »
Please use pms for private chat, Thanks,

LL


And I Play:  Mafia-Mandemz

Offline zilchuary

  • SMF For Free Newbie
  • *
  • Posts: 16
    • View Profile

  • Total Badges: 10
    Badges: (View All)
    Topic Starter Combination Level 2 Level 1 10 Posts
Re: java multithreading ... Explaining
« Reply #2 on: July 09, 2008, 06:15:52 am »
Okay sorry  :D

 

Related Topics

  Subject / Started by Replies Last post
4 Replies
6607 Views
Last post July 11, 2007, 12:40:04 pm
by doggiedoo86
3 Replies
10078 Views
Last post February 04, 2009, 07:44:58 pm
by nondier
1 Replies
4785 Views
Last post June 16, 2008, 02:30:19 am
by Supernovadelta
1 Replies
5202 Views
Last post July 02, 2008, 01:16:07 pm
by Jessie
10 Replies
12977 Views
Last post January 09, 2010, 01:57:39 pm
by hell hound