Home Java Thread Overview of Thread
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

Overview of Thread

Advertisement
In this section, you will read about overview of thread in java.

Overview of Threads

     

Process

A process is an instance of a computer program that is executed sequentially. It is a collection of instructions which are executed simultaneously at the rum time. Thus several processes may be associated with the same program. For example, to check the spelling is a single process in the Word Processor program and you can also use other processes like printing, formatting, drawing, etc. associated with this program.

Thread

A thread is a lightweight process which exist within a program and executed to perform a special task. Several threads of execution may be associated with a single process. Thus a process that has only one thread is referred to as a single-threaded process, while a process with multiple threads is referred to as a multi-threaded process.

In Java Programming language,  thread is a sequential path of code execution within a program. Each thread has its own local variables, program counter and lifetime. In single threaded runtime environment, operations are executes sequentially i.e. next operation can execute only when the previous one is complete. It exists in a common memory space and can share both data and code of a program. Threading concept is very important in Java through which we can increase the speed of any application. You can see diagram shown below in which a thread is executed along with its several operations with in a single process. 

Main Thread

When any standalone application is running, it firstly execute the main() method runs in a one thread, called the main thread. If no other threads are created by the main thread, then program terminates when the main() method complete its execution. The main thread creates some other threads called child threads. The main() method execution can finish, but the program will keep running until the all threads have complete its execution.

Advertisements

Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: April 17, 2007

Ask Questions?    Discuss: Overview of Thread   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
Ashok
March 5, 2012
java program

Give real time examples for Thread concepts in Java
sachin bhanot
April 7, 2012
process vs thread

i cant find a exact meaning of difference between process and thread plz give example of both process and thread
Tamilselvan J B
June 25, 2012
Spelling Mistake

here it is specified like "at the rum time". I think it has to be "at the run time" Thanks
Reegan Bose
August 8, 2012
Kindly Provide Technical Emails

Respected Developer, Please provide some c,c++,java,python program instruction throw Emails,Then How to easy develop java? send links to me. Thanking You
apsingh
October 19, 2012
what is mean by thread why use in java

what is mean by thread why use in java
DMCA.com