zoukankan      html  css  js  c++  java
  • 222

    int tickets = 100;

        String string = "";

     

    executor.execute(new Runnable() {

                @Override

                public void run() {

                    while (tickets > 0) {

                        synchronized (string) {

                            try {

                                if (tickets > 0) {

                                    System.out.println(Thread.currentThread().getName()

                                            + "卖出了第" + (tickets--) + "张票");

                                    Thread.sleep(1000);

                                }

     

                            } catch (Exception e) {

                                e.printStackTrace();

                            }

                        }

                    }

                    

                }

            });

  • 相关阅读:
    Selenium RC For Python:教程2
    sql server 获取同比或环比
    C#泛型泛型集合Dictionary<K,V>
    C# FileStream
    c# 强命名的作用
    装箱与拆箱的概念及意义
    SQL Server中Rollup关键字使用技巧
    Javascript内存泄露
    几条复杂的SQL语句
    Group by与having理解
  • 原文地址:https://www.cnblogs.com/yc5518/p/9268548.html
Copyright © 2011-2022 走看看