相关疑难解决方法(0)

ThreadGroup在创建单独的线程方面有什么好处?

许多方法,如stop(),resume(),suspend()等已被弃用.

那么使用ThreadGroup?创建线程是否有用?

java multithreading

21
推荐指数
3
解决办法
2万
查看次数

什么是Java中的线程组?

我想知道为什么互联网上关于线程组的文档很少?它们仍在使用,或者它们是一些陈旧的概念?有人可以解释一下:

  • 它们是什么.

  • 它们用于什么.

  • 如果他们是平静的使用,在哪里?

  • 给出一些真实的应用程序示例(可能是Web服务器).

java multithreading

13
推荐指数
1
解决办法
379
查看次数

Java中的ThreadGroup

我目前正在学习Java中的Threads基础知识,我正在尝试编写一个简单的Thread Group程序.虽然我得到了不同类型的输出,但我和教程网站一样写了它.下面是我的代码,我得到不同的输出.

public class ThreadGroupDemo implements Runnable {

    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName());
        // get the name of the current thread.
    }

    public static void main(String[] args) {
        ThreadGroupDemo runnable = new ThreadGroupDemo();
        ThreadGroup tg1 = new ThreadGroup("Parent Group");
        // Creating thread Group.

        Thread t1 = new Thread(tg1, new ThreadGroupDemo(), "one");
        t1.start();
        t1.setPriority(Thread.MAX_PRIORITY);

        Thread t2 = new Thread(tg1, new ThreadGroupDemo(), "second");
        t2.start();
        t2.setPriority(Thread.NORM_PRIORITY);

        Thread t3 = new Thread(tg1, new ThreadGroupDemo(), "Three");
        t3.start();

        System.out.println("Thread Group name : " + tg1.getName()); …
Run Code Online (Sandbox Code Playgroud)

java multithreading threadgroup

7
推荐指数
1
解决办法
871
查看次数

标签 统计

java ×3

multithreading ×3

threadgroup ×1