前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Java多线程不共享数据

Java多线程不共享数据

作者头像
葆宁
发布2019-04-18 15:19:10
1.2K0
发布2019-04-18 15:19:10
举报
文章被收录于专栏:FREE SOLOFREE SOLO
代码语言:javascript
复制
import org.omg.CORBA.PUBLIC_MEMBER;

/**
 * Created by wuyupku on 2019-04-12 12:24
 *
 * @Beijing CHINA
 */
public class Demo01 {
    public static void main(String[] args) {
        mythread thread1 = new mythread("a");
        mythread thread2 = new mythread("b");
        mythread thread3 = new mythread("c");
        mythread thread4 = new mythread("d");
        thread1.start();
        thread2.start();
        thread3.start();
        thread4.start();
        System.out.println("运行结束");
    }
}
class mythread extends Thread {
    private int count = 5;

    public mythread(String name) {
        super();
        this.setName(name);
    }

    @Override
    public void run() {
        super.run();
        while (count > 0) {
            count--;
            System.out.println("由" + this.currentThread().getName() + "计算,count" + count);
        }
    }
}
在这里插入图片描述
在这里插入图片描述
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019年04月12日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档