Java Concurrency - Process (Main thread)

Java Conceptuel Diagram


process in Java

A process in Java is:

  • started by a main class.
  • implemented as a main thread that can create other thread.

It has:

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



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


The jps command will report the local VM identifier, or lvmid for each instrumented JVM found on the target system (The lvmid is generally the operating system's process identifier).

More Java - jps (Java Process Utility)

Get Pid

From Jps

with Java - jps (Java Process Utility)

jps | grep -i name | awk '{print $1}'

From Java

import java.lang.reflect.Field;
import java.lang.reflect.Method;

public static int getCurrentPID() {
    try{ runtime = 
        java.lang.reflect.Field jvm = runtime.getClass().getDeclaredField("jvm");
        jvm.setAccessible(true); mgmt = 
           ( jvm.get(runtime);
        java.lang.reflect.Method pid_method = 
        return (Integer) pid_method.invoke(mgmt);
    catch(Exception e){
        System.out.println("Failed at getting the process ID");

Name - Set process name for Java on Linux

Discover More
Eclipse Main Class
Java - (Main|Start) Class

in Java is called a Main class. The (Main|Start) class is a class that: have a main method will start the main thread (process) main classjar You can start the java application by: calling...
Java Conceptuel Diagram
Java - Concurrency (Parallel Work)

In concurrent or parallel programming, there are two basic units of execution: processes. A process is implemented as a main thread that can create other thread. and threads. Threads exist within...
Java Conceptuel Diagram
Java - Process

in Java See
Thread Java Mission Control
Java Concurrency - Thread

Every application has at least one thread . From the application programmer's point of view, you start with just one thread, called the main thread. From this thread, you can start other threads. ...

Share this page:
Follow us:
Task Runner