Definition
A thread is a lightweight process. And what's a process ? A process is described as an instance of a program that is running. A program is code and when it is running there is data, memory involved in addition to code. Every process must have at least 1 thread . The thread has access to the main memory and has it's own stack. However what makes the thread special is that a thread has a single sequential path of execution. So 2 threads in a single program can have their own paths of execution and it is not possible to predict the overall sequence of steps. ( Threading in Java 5.0 is vastly different from the JDK 1.4.2 . We shall cover the JDK 1.4.2 and then move to Java 5.0 ) .
JDK 5.0 gives more control over threads and synchronization and allows complex threading algorithms to be implemented. All the Threading options offered by JDK 1.4.2 are supported by 5.0 . There are several new packages:
java.util.concurrent ( Utility Classes. Executor classes. Concurent containers. )
java.util.concurrent.locks ( Classes for locks )
java.util.concurrent.atomic ( Classes that provide atomicity for primitives )