Java — Constructors of ThreadGroup Class | Code Factory

  • Create a new Thread Group with specified group name.
  • The parent of this new group is the thread group of currently executing thread.
package com.example.thread;public class Test {
public static void main(String... args) {
ThreadGroup tg1 = new ThreadGroup("Group1");
System.out.println(tg1.getName()); // Group1
System.out.println(tg1.getParent().getName()); // main
}
}
  • Creates a new Thread Group with the specified group name.
  • The parent of this new thread group specified parent group.
package com.example.thread;public class Test {
public static void main(String... args) {
ThreadGroup tg1 = new ThreadGroup("Group1");
System.out.println(tg1.getName()); // Group1
System.out.println(tg1.getParent().getName()); // main

ThreadGroup tg2 = new ThreadGroup(tg1, "Group2");
System.out.println(tg2.getName()); // Group2
System.out.println(tg2.getParent().getName()); // Group1
}
}

--

--

--

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

Recommended from Medium

What I have learnt so far about free coupom on Udemy courses

MetaMind Thursdays-Meet Betterdata

Rails: In search of DRY-Land

Linux Address Space

AMA Recap held on ChainBoost on Oct 22, 2021

Saving Data Input from A Web (HTML) into SPIFFS (with Arduino IDE and ESP32)

Azure Active Directory(Azure AD) Explained

Production management system supporting LEAN and BIM

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

JAVA 16 And 17: Evolutions and new features — Part 1

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

Unit Testing Apache Camel

Spring Boot Tests with Kotlin and Embedded Kafka