❮ Previous Next ❯

Java Multithreading:

Before knowing multithreading, first we have to know about the concept of multi-tasking. When multiple tasks are executing simultaneously, is known as multi-tasking.

For example, in a class room, while a faculty is teaching, the sitting students are doing multiple activities: such as listening the lecture, at the same time they are writing the notes, at the same time some students are in sleeping mood and at the same time some students are busy with their mobiles. So all these activities they are doing simultaneously. Hence this is called as multi-tasking. Similarly multitasking allows several activities to occur concurrently on the computer.

Basically there are two types of multitasking, such as

Process based multi-tasking:

Executing multiple tasks simultaneously where each task is a separate independent process is known as process based multi-tasking. For example; while writing a java program in the editor, we can listen music through MP3 player. At the same time we can download a file from the internet. All these tasks are executing simultaneously and independent of each other. So it is called as process based multi-tasking. It is best suitable at operating system level.

Disadvantages :

Thread based multi-tasking:

Thread based multi-tasking is called as multithreading. Executing multiple tasks simultaneously where each task is a separate independent part of same program is known as thread based multi-tasking. It is best suitable at programmatic level. Java provides inbuilt support for thread based multi-tasking by providing varieties of library (Thread, Runnable etc...).

The purpose of multitasking is to reduce the response time and improve performance of the system whether it is process based or thread based. There are different areas where multithreading concept is used, such as video games, animation movies, multimedia graphics, server side etc..

Here I am presenting some advantages of thread-based multitasking as compared to process-based multitasking which are as follows:

Java supports thread-based multitasking and provides high-level facilities for multi-threaded programming. Thread safety is the term used to describe the design of classes that ensure that the state of their objects is always consistent, even when the objects are used concurrently by multiple threads.

Overview of Threads:


class ThreadDemo
public static void main(String args[ ])
Thread t=Thread.currentThread( );
System.out.println("current thread is"+t);
System.out.println("the name of thread is"+t.getName());

current thread is Thread[main,5,main]
the name of thread is main

❮ Previous Next ❯


Popular Links

Contact Us

address Plot No-N6/530,2ND Floor
Nayapalli,Jayadev Vihar
      Email: info@silantechnology.com
      Phone: 0674-2361252
39877, sundale dr, apt#101, Fremont, California 94538, USA
       Phone: +1(262)388-7619

facebook twitter google linked in

© 2018 Silan Technology. All Rights Reserved