17.2 Generating Existing Threads and New Threads
In this section, we’ll illustrate how the concurrent program code is packaged into a Runnable and presented to the thread for execution.
17.2.1 Main Thread
Every program code in Java always runs in a thread. When the JVM starts, it automatically creates a thread called the main thread . This thread processes the main(...) method. Everything you put in the main(...) method is processed by the main thread, which can be easily seen in a debugger.
Usually, other threads exist in the Java environment, which are started by the system via the help of libraries. When Java opens a window, for instance, a GUI thread is started in which related events are processed.
17.2.2 Who Am I?
In Java, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access