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.

|
Current Comments
2 comments so far (post your own) View All Comments Latest 10 Comments:above you should have to write the block diagram of multi-threads.
Posted by vikash on Sunday, 04.27.08 @ 08:15am | #57971
im from a small town in ohio and it takes us forever to get good songs on the radio and by the time they make it,
they are so over played...help me find some sweet new rap.
Posted by Teepjegovem on Thursday, 01.24.08 @ 15:11pm | #46006