0
点赞
收藏
分享

微信扫一扫

ThreadDemo4


package com.shrimpking.t1;

/**
 * Created by IntelliJ IDEA.
 *
 * @Author : Shrimpking
 * @create 2024/9/21 16:57
 */
class TestThread4 extends Thread{
    private int tickets = 5;

    @Override
    public void run(){
        while (tickets > 0){
            System.out.println(Thread.currentThread().getName() +"出票" + tickets);
            tickets -= 1;
        }
    }
}

//ch15-4 多线程模拟售票
public class ThreadDemo4
{
    public static void main(String[] args)
    {
        TestThread4 th = new TestThread4();

        th.start();
        th.start();
        th.start();
        th.start();

    }
}

举报

相关推荐

2022/4/4

2022/4/4偷懒

实验4:4-8

实验4:4-12

4月4日java作业

0 条评论