Java Multiple Thread Overview

Multiple thread is supported by java as a built-in feature. One same code snippet can be executed multiple times at the same time in multiple thread programming. Each execution that run the java code is called as a thread.

Every popular operating systems support multitasking. And multitasking is divided into two types as thread-based and process-based. There are a lot of difference between them.

A process is an executing program. Process-based multitasking allows two or more programs executed on your computer concurrently. You can run a web browser or using word editor at the same time in process based multitasking. A software program is the minimal unit of code snippet which can be dispatched by system scheduler.

In the thread-based multitasking system, thread is the minimal unit of code that can be dispatched. So one particular program can execute several jobs concurrently. For example, a words editor can save document while it is editing, because there has two separate threads to execute the two actions.

Multitasking processes need much more expenses than multitasking threads. Because processes need their own individual address areas and there has limit and cost expensive for two or more process to communicate so they are heavyweight tasks. It is also very costly to switch context between two processes.

But threads are less heavy. The exact same process and address space are shared between threads. Inter-thread communication and context switching is inexpensive.

Although Java programs take advantage of process-based multi-tasking system, but java dose not use process-based multi-tasking. Java only use thread-based multitasking. You will feel more convenient when use Java managed threads because you do not need to care about the details, all details is handled by java.



Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.