Technical Blog Of JackCHAN

August 10, 2010

Java concurrent programming (1) — Process and Thread

Filed under: concurrent, java — Tags: , , , — kaisechen @ 6:16 am

There are two units associated with concurrent programming: process and thread. But in Java environment, it is mostly concerned with Thread.

Process

A process has a self-contained executive environment, which owns  a complete , private  set of run-time resources and occupied memory space.

In most situation, it is called program or application. But actually,  a single application may be consist of  a set of cooperating processes. Processes need communicate with each other, and most OSs support Inter Process Communication(IPC) resources, e.g. pipes and sockets.

In Java environment, JVM(Java Virtual Machine) mostly runs as a single process.  However, a Java application can create additional processes using a ProcessBuilder object.

Thread

Some people calls thread ‘lightweight process’.  Thread provides an execution environment like process, but less resource is required when creating a thread than creating a process.

Thread exists in process, so a process at least own a thread.

Threads exists in a process will share the process’s resource including memory and open files.

Java platform supports multi-thread, a Java application starts with one thread — ‘Main thread’,  main thread can create additional threads.

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

Create a free website or blog at WordPress.com.