Java threads

A thread in Java is a program execution and is built into the JVM. The Thread class is part of the java.lang package (java.lang.Thread). Threads have priorities that control in what order the JVM executes them. While the concept is simple, implementation is not. Let's start by taking a close look at the Thread class.

The Thread class has two nested classes:

  • public static enum Thread.State
  • public static interface Thread.UncaughtExceptionHandler

There are three instance variables for managing thread priorities:

  • public static final int MAX_PRIORITY
  • public static final int MIN_PRIORITY
  • public static final int NORM_PRIORITY

The Thread class has eight constructors, all of which allocate a new Thread object. Here are the constructor ...

Get Java 9: Building Robust Modular Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.