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

How Much Does It Cost to Develop a Voice Chat App

Exception handling and Database Transaction in Laravel  — Part 1

Files in Linux System Programming

Perfect Your Ballerina Act — With Testerina

How to use the AWS Global Accelerator

A Tale of Two Traits

Introduction to Bash Script — 2

Getting Started with Disassembling Python Code

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

Explore Prototype Design Pattern

SOLID Principles

How to implement Visitor Design Pattern using Java?

SOLID Principles in Java