码迷,mamicode.com
首页 > 编程语言 > 详细

多线程问题

时间:2018-10-12 15:59:17      阅读:177      评论:0      收藏:0      [点我收藏+]

标签:==   ring   protect   div   getname   override   hashmap   current   cte   

 

 

public class ReadSku extends Logger{
    static  class Num implements Runnable{
        public int a = 0;
        @Override
        public void run() {
            synchronized (Num.class){
                for (int i = 0; i < 10; i++) {
                    System.out.println(Thread.currentThread().getName()+"========"+a++);
                }
            }
        }
    }
    protected ReadSku(String name) {
        super(name);
    }
    static Logger logger = Logger.getLogger(ReadSku.class);
    public static void main(String[] args) throws IOException {
//        HashMap map = new HashMap<>();
//        getprice();//单个遍历表信息
        Num num1 = new Num();
        Num num2 = new Num();
        Num num3 = new Num();
        Thread thread1 = new Thread(num1);
        Thread thread2 = new Thread(num2);
        Thread thread3 = new Thread(num3);
            thread1.start();
            thread2.start();
//            thread3.start();
    }

 

多线程问题

标签:==   ring   protect   div   getname   override   hashmap   current   cte   

原文地址:https://www.cnblogs.com/kuoAT/p/9778176.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!