Total members 10261 | Gratitudes |It is currently Wed May 23, 2012 10:10 am Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 1 post ] 
Author Question
 Question subject: What is Multithreading?
PostPosted: Wed Jul 04, 2007 12:15 am 
Offline
Beginner
User avatar

Joined: Wed Mar 28, 2007 1:17 pm
Posts: 118
Location: Cairo-Egypt
Has thanked: 0 time
Have thanks: 5 time

What is Multithreading?
-----------------------------------------


A thread executes a series of instructions. Every line of code that is executed is done so by a thread. Some threads can run for the entire life of the applet, while others are alive for only a few milliseconds.

Multithreading is the ability to have various parts of program perform program steps seemingly at the same time. Java let programs interleave multiple program steps through the use of threads. For example,one thread controls an animation, while another does a computation. In Java, multithreading is not only powerful, it is also easy to implement.

You can implement threads within a java program in two ways ط£آ¢أ¢â€ڑآ¬أ¢â‚¬إ“ Creating an object that extends Class Thread or implementing the interface Runnable.

The key difference between the two is that Thread class has a strart() method which your program simple calls whereas the Runnable class does not have a start method and you must create a Thread object and pass your thread to its constructor method. You never call run() method directly; the start method calls it for you.

Example:

Code:
Class MyProcess extends Thread{
   Public void run(){
}
   public static void main(String args[]){
      MyProcess mp = new MyProcess();
      mp.start();
}
}
Class MyProcess implements Runnable {
Public void run(){
}
public static void main(String args[]){
      Thread mp = new Thread(new MyProcess());
      mp.start();
}
}
]


TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 1 post ] 
Quick reply


  

 Similar topics
 Java - Multithreading
 C++ Multithreading

All times are UTC [ DST ]


Users browsing similar posts

Users browsing this forum: Google [Bot], Google Adsense [Bot] and 2 guests



Jump to:  
Previous Question | Next Question 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team