小编use*_*892的帖子

什么时候主线死了?

问题是使用线程生成1到99之间的随机数.不过这里的问题是我不知道"主要线程停止"从何而来?主线是不是最终死了?

这是示例输出:

Main thread stopping
Random no = 57
Random no = 47
Random no = 96
Random no = 25
Random no = 74
Random no = 15
Random no = 46
Random no = 90
Random no = 52
Random no = 97
Thread that generates random nos is stopping
Run Code Online (Sandbox Code Playgroud)

神话类:

public class MyThread extends Thread {
    MyThread() {
        // default constructor
    }

    MyThread(String threadName) {
        super(threadName); // Initialize thread.
        start();
    }

    public void run() {
        // System.out.println(Thread.currentThread().getName()); …
Run Code Online (Sandbox Code Playgroud)

java multithreading

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

标签 统计

java ×1

multithreading ×1