Multi Tasking:
Within a thread-based multitasking environment, a thread is the smallest unit of dispatchable code. This means in which a single program could perform two or more tasks concurrently. For example, a text editor can format text at the similar time in which it is printing, as long as these two actions are being performed through two separate threads.
Therefore, process-based multitasking deals along with the "big picture" and the thread-based multitasking handles the details.
Multitasking threads needs fewer overheads than multitasking processes. Processes are heavy weight tasks which require their own separate address space. An Inter-process communication is limited and expensive. A Context switching from one process to another is also costly. Threads, alternatively, are lightweight. They share the similar address space and cooperatively share the similar heavyweight procedure. In Inter thread communication is inexpensive and context switching from one thread to the next is low cost. Although Java programs make use of process-based multitasking environments and process-based multitasking is not under the control of Java. Though, multithreaded multitasking is.
Multithreading enables you to write extremely efficient programs which make maximum use of the CPU, since idle time could be kept to a minimum. This is especially significant for the interactive, networked environment in that Java operates, since idle time is general. For instance, the transmission rate of data over a network is much slower than the rate at that the computer could process it. Even local file system resources are read and written at a much slower pace than they could be processed through the CPU. And, of course, user input is much slower than the computer. Within a traditional, single-threaded environment your program has to wait for every of these tasks to finish before it can proceed to the next one - even by the CPU is sitting idle most of the time. A Multithreading lets you gain access to this idle time and put it to good use.
You are already familiar along with multithreaded programming if you have programmed for OS such as Windows 98 or Windows NT. However, the fact in which Java maintain threads makes multithreading especially convenient, since several of the details are handled for you.