Multithreading & Synchronization
Multithreading: Execution of more than one thread at a time is called as multithreading. Thread: A thread is a piece of code that executes independently. Every program contains at least one thread. i.e. main thread Main thread default name is main only. Main thread default priority is normal priority(Priority number is 5) There are two ways to create a new thread: 1) By extending java.lang.Thread class 2) By implementing a java.lang.Runnable interface Life cycle of a thread (or) thread states: Whenever thread class constructor is called new thread will born. Thread comes to a ready state whenever start() method is called. Thread will run whenever run() method is called. Thread comes to a sleeping state whenever sleep() method is called. Sleeping thread will wake up automatically whenever time interval is finished. Thread is suspended whenever suspend() method is called. Suspended thread will run whe...