多线程按顺序打印数字,支持配置线程数目和打印数字结尾

2021-01-24 19:16

阅读:458

标签:dprint   stat   system   void   static   atom   false   配置线   creat   

import java.util.concurrent.atomic.AtomicInteger;

/**
 * @author zerodsLyn
 * created on 2020/5/10
 */
public class MultiThreadSerialPrint {
    private final Thread[] threads;
    /**
     * 打印线程数目
     */
    final int threadNum;

    AtomicInteger num;

    private final int end;
    /**
       * 打印任务是否结束
       */
    volatile boolean running = true;

    public ThreadPrint(int threadNum, int end) {
        this.num = new AtomicInteger(0);
        this.end = end;
        this.threadNum = threadNum;
        this.threads = new Thread[threadNum];
        for (int i = 0; i 

多线程按顺序打印数字,支持配置线程数目和打印数字结尾

标签:dprint   stat   system   void   static   atom   false   配置线   creat   

原文地址:https://www.cnblogs.com/zerodsLearnJava/p/12864500.html


评论


亲,登录后才可以留言!