Java — Multithreading Enhancement | Code Factory

  • Based on functionality we can group threads into a single unit which is nothing but Thread Group that is Thread Group contains a group of threads.
  • In addition to threads, Thread Group can also contain sub thread groups.
  • The main advantage of maintaining threads in the form of thread group is we can perform common operations very easily.
  • Every thread in Java belongs to some group.
  • Main thread belongs to main group.
  • Every thread group in Java is a child group of system group either directly or indirectly. Hence system group act as root for all thread groups in Java.
  • * System group contains several system level threads like finalizar, refernce handler, signal dispatcher, attach listener.
package com.example.thread;public class Test {
public static void main(String... args) {
System.out.println(Thread.currentThread().getThreadGroup().getName()); // main
System.out.println(Thread.currentThread().getThreadGroup().getParent().getName()); // system

//Thread.currentThread() --> main thread
//Thread.currentThread().getThreadGroup() --> main thread group
//Thread.currentThread().getThreadGroup().getParent() --> system thread group
  • Thread Group is a Java class present in java.lang package and it is direct child class of Object.
  1. Constructors of ThreadGroup Class
  2. Important Methods of ThreadGroup Class
  3. java.util.concurrent package
  4. java.util.concurrent.locks.Lock Interface
  5. java.util.concurrent.locks.ReentrantLock
  6. Thread Pools (Executor Framework)
  7. Callable & Future
  8. ThreadLocal




Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Dapplets extension — 0.48.0

Practical SQL: Designing and Creating a Relational Database

Meltano — build a tap: from zero to hero in 10 minutes

Automated Trading with Deephaven — Part 2

GCP Storage Transfer Service Job using AWS ARN

Web Scraping Popular Movies using BeautifulSoup

How to Add a Custom Domain To Your AWS WebSocket

Unity Analytics

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Code Factory

Code Factory

More from Medium

Unit Testing Apache Camel

Exploring What’s Inside java.util.concurrent Package (Part 1)

From JAVA 9 to JAVA 15: Evolutions and new features — Part 1

Java Microservice Layer Architecture