标签:class read down 下载 let code title blank com
下面我们再给出一个线程不安全的例子。 (视频下载) (全部书籍)
例:1.8.2-本章源码
class BookMark_to_win {
int bookNum=10;
void onlySellOne() {
if (bookNum > 0) {
System.out.println(Thread.currentThread().getName()
+ " before" + bookNum);
bookNum--;
try {
Thread.sleep(1000);
} catch (Exception e) {
}
System.out.println(Thread.currentThread().getName()
+ " after " + bookNum);
}
}
}
public class Test {
public static void main(String[] args) {
BookMark_to_win bookM = new BookMark_to_win();
while (bookM.bookNum>0) {
。。。。。。。。。。。。。。。。。
详情请进:http://www.mark-to-win.com/index.html?content=JavaBeginner/javaUrl.html&chapter=JavaBeginner/JavaBeginner6_web.html#WhatIsThreadNonSafe
标签:class read down 下载 let code title blank com
原文地址:https://www.cnblogs.com/mark-to-win/p/9696256.html