Processes and Threads in Java programming language

by Clain Brand.

Share
|
Homepage | Submit your article | Contact | TOS
More articles on java  

You are here: Categories » Computers and technology » JAVA

In concurrent programming, there are two basic units of execution: processes and threads. In the Java programming language, concurrent programming is mostly concerned with threads. However, processes are also important.

A computer system normally has many active processes and threads. This is true even in systems that only have a single execution core, and thus only have one thread actually executing at any given moment. Processing time for a single core is shared among processes and threads through an OS feature called time slicing.

It's becoming more and more common for computer systems to have multiple processors or processors with multiple execution cores. This greatly enhances a system's capacity for concurrent execution of processes and threadsbut concurrency is possible even on simple systems without multiple processors or execution cores.

Processes

A process has a self-contained execution environment. A process generally has a complete, private set of basic run-time resources; in particular, each process has its own memory space.

Processes are often seen as synonymous with programs or applications. However, what the user sees as a single application may in fact be a set of cooperating processes. To facilitate communication between processes, most operating systems support Inter Process Communication (IPC) resources, such as pipes and sockets. IPC is used not just for communication between processes on the same system, but processes on different systems.

Most implementations of the Java virtual machine run as a single process. A Java application can create additional processes using a ProcessBuilder object.

Threads

Threads are sometimes called lightweight processes. Both processes and threads provide an execution environment, but creating a new thread requires fewer resources than creating a new process.

Threads exist within a processevery process has at least one. Threads share the process's resources, including memory and open files. This makes for efficient, but potentially problematic, communication.

Multithreaded execution is an essential feature of the Java platform. Every application has at least one threador several, if you count "system" threads that do things like memory management and signal handling. But from the application programmer's point of view, you start with just one thread, called the main thread. This thread has the ability to create additional threads.

Leave a comment or ask a question
Total comments: 0

JAVA Disclaimer

  • The e-articles directory is not responsible for any and all copyright infringements by writers and authors. If you suspect the information contained by this page for any copyright infringements, please contact us to investigate the issue
Arithmetic Assignment Operators - The following assignment operators are similar to the increment and decrement operators that we have just seen. They are used so that you do not need to enter the source variable twice when ass (more...)
Bitwise Operators - The following table shows the standard bitwise operators in Java and a description of them. (more...)
Invocation Chaining - Invocation chaining means that you are not limited to merely accessing one class/object member in a given statement with the . operator but may continue to access further members in a given stateme (more...)
Regular Expressions in Java - A regular expression is a code that is used to match a pattern in a given string and is new to Java 1.4. Regular expressions are made up of normal characters and metacharacters. Normal characters a (more...)
Character Escape Sequences - Character escape sequences allow for a character to be interpreted differently than its literal value. Character escape sequences are defined using the backslash (\) character, followed by th (more...)
Conditional Statements - The ability to choose the path that your program takes, based on any given data, is the key to all functionality in programming. In order to create conditional statements, we must first learn a (more...)
Java Methods - Methods are used as the building blocks of your program, performing tasks that can be called again and again and using the same code to perform the task each time. The basic but fundamental parts o (more...)
Variable Scope - The scope of a variable is the area in which a variable belongs, specified by the area in which it is declared. The following example code contains two declared variables, one inside a code block a (more...)
What is a Java Package - A Java package is a collection of related classes that can be imported into your program to support your software. They also provide namespace management, as well as access protection. (more...)
Importing Java Packages - To use a package within a Java application or applet, we need to import it. We do this by means of the import keyword. So, for example, if we wish to include the I/O package, which is called java.i (more...)

 
free content
    Copyright © 2006 - 2012 e-articles.info.
The texts, articles and tutorials in the directory are property of their respective owners and authors.