threadgroup

ThreadGroup类的list()方法 (ThreadGroup Class list() method)

  • list() method is available in java.lang package.

    list()方法在java.lang包中可用。

  • list() method is used to list or display information (like name, priority, thread group, etc.) to the standard output about this thread group.

    list()方法用于将信息(例如名称,优先级,线程组等)列出或显示到有关此线程组的标准输出。

  • list() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.

    list()方法是一种非静态方法,只能通过类对象访问,如果尝试使用类名称访问该方法,则会收到错误消息。

  • list() method does not throw an exception at the time of displaying information about this thread group.

    在显示有关此线程组的信息时, list()方法不会引发异常。

Syntax:

句法:

    public void list();

Parameter(s):

参数:

  • It does not accept any parameter.

    它不接受任何参数。

Return value:

返回值:

The return type of this method is void – it returns nothing.

此方法的返回类型为void –不返回任何内容。

Example:

例:

// Java program to demonstrate the example
// of void list() method of ThreadGroup
public class ListThreadGroup implements Runnable {public static void main(String[] args) {ListThreadGroup list_tg = new ListThreadGroup();
list_tg.listTG();
}
public void listTG() {try {// Create two thread group and the named are base
// and derived
ThreadGroup base = new ThreadGroup("Base ThreadGroup");
ThreadGroup derived = new ThreadGroup(base, "Derived ThreadGroup");
// create two threads
Thread th1 = new Thread(base, this);
Thread th2 = new Thread(derived, this);
// By using getName() method is to retrieve the
// name of the thread th1
System.out.println(th1.getName() + " " + "begins.....");
// By using start() method is to start its execution
// of thread th1
th1.start();
// By using getName() method is to retrieve the
// name of the thread th2
System.out.println(th2.getName() + " " + "begins.....");
// By using start() method is to start its execution
// of thread th2
th2.start();
System.out.println();
// By using list() method is to
// list the contents of the
// thread group to the std. output
System.out.println("base.list() :");
base.list();
System.out.println();
System.out.println("derived.list() :");
derived.list();
// By using join() method is to wait the current
// thread till complete execution of another
// thread
th1.join();
th2.join();
} catch (InterruptedException ex) {ex.printStackTrace();
}
}
// Override run()
public void run() {for (int k = 0; k < 100; ++k)
++k;
System.out.println(Thread.currentThread().getName() + " " + "ends.....");
}
}

Output

输出量

Thread-0 begins.....
Thread-0 ends.....
Thread-1 begins.....base.list() :
Thread-1 ends.....
java.lang.ThreadGroup[name=Base ThreadGroup,maxpri=10]java.lang.ThreadGroup[name=Derived ThreadGroup,maxpri=10]derived.list() :
java.lang.ThreadGroup[name=Derived ThreadGroup,maxpri=10]

翻译自: https://www.includehelp.com/java/threadgroup-list-method-with-example.aspx

threadgroup

threadgroup_Java ThreadGroup list()方法与示例相关推荐

  1. threadgroup_Java ThreadGroup toString()方法与示例

    threadgroup ThreadGroup类的toString()方法 (ThreadGroup Class toString() method) toString() method is ava ...

  2. java setdaemon_Java ThreadGroup setDaemon()方法

    Java ThreadGroup setDaemon()方法 java.lang.ThreadGroup.setDaemon() 方法改变该线程组的守护进程的状态.当其最后一个线程被停止或它的最后一个 ...

  3. .net连接mysql数据_.net连接MYSQL数据库的方法及示例!

    连接MYSQL数据库的方法及示例 方法一: 使用MYSQL推出的MySQL Connector/Net is an ADO.NET driver for MySQL 该组件为MYSQL为ADO.NET ...

  4. set.difference() 的用法(python3)_Python 集合 difference_update() 使用方法及示例

    Python 集合 difference_update() 使用方法及示例 Difference_update()使用集合的差集更新集合,并调用difference_update()方法. 如果A和B ...

  5. doc python 颜色_Python wordcloud.ImageColorGenerator方法代码示例

    本文整理汇总了Python中wordcloud.ImageColorGenerator方法的典型用法代码示例.如果您正苦于以下问题:Python wordcloud.ImageColorGenerat ...

  6. isdigit函数在C语言什么意思,C 库函数 isdigit() 使用方法及示例

    C 库函数 isdigit() 使用方法及示例 isdigit()函数检查字符是否为数字字符(0-9). isdigit()的函数原型int isdigit( int arg ); 函数isdigit ...

  7. python中append的用法_Python 列表 append() 使用方法及示例

    Python 列表 append() 使用方法及示例 append()方法将一个项目添加到列表的末尾. append()方法将单个项目添加到列表的末尾. append()方法的语法为:list.app ...

  8. java kryo_Kryo框架使用方法代码示例

    Kryo框架的source已移至https://github.com/EsotericSoftware/kryo ,进入此页面,然后点击右边的Download Zip按钮,就能下载到最新版本的Kryo ...

  9. python文件的用法,Python 文件 readlines() 使用方法及示例

    Python 文件 readlines() 使用方法及示例 概述 readlines() 方法用于读取所有行(直到结束符 EOF)并返回列表,该列表可以由 Python 的 for... in ... ...

  10. php一些单选、复选框的默认选择方法(示例)

    转载 http://www.php.cn/php-weizijiaocheng-360029.html 一. radio和checkbox及php select默认选择的实现代码 1.radio单选框 ...

最新文章

  1. 每日一皮:后来…后来…他得到了永生...
  2. Xcode执行Analyze静态分析
  3. linux gst-launch 播放视频旋转,【视频开发】Gstreamer中一些gst-launch常用命令
  4. oracle建共享dblink,oracle建多个dblink
  5. vue element form 默认校验
  6. 灵魂拷问!java数据结构面试题
  7. hausaufgabe--python 11-List slice
  8. Fiddler抓包一键生成代码
  9. Dstream如何应用RDD特有算子?
  10. unityui计分_铅计分成长
  11. SwitchHosts
  12. Python入门学习—列表(FishC)
  13. struct termios结构体详解
  14. Linux操作系统安全防护指导手册(详细截图)
  15. SVG 研究之路 - 再談 defs
  16. ch341a编程器写操作超时失败
  17. 【大一上】C++小知识点
  18. ARM Cortex-M处理器详解
  19. ElementUI 整体页面布局
  20. 备忘录怎么完整发给别人

热门文章

  1. Ubuntu 18.04 安装OpenCV C++
  2. [分布式训练] 单机多卡的正确打开方式:理论基础
  3. 计算机语言低下限高上限,学习语言有没有上限
  4. Qt图形界面编程入门(1)
  5. 华为笔记本会不会用鸿蒙,华为MateBook Pro笔记本为什么不用鸿蒙操作系统HarmonyO?...
  6. oracle连续状态相同,数据库共有三种状态:quiesce、resrict、suspend
  7. php用到的mysql语句_PHP中常用到的一些MySQL语句_php
  8. 简单的签到代码_PHP实现一个小小的签到功能,到底用MySQL还是Redis?
  9. MySQL 之binlog日志说明及利用binlog日志恢复数据操作记录
  10. LDAP命令介绍---import-ldif