4月17日,TestCommunicate,每日20行。
来源:互联网 发布:音乐声音放大软件 编辑:程序博客网 时间:2024/06/14 00:24
class Account{ volatile private int value; void put(int i){ value = value + i; System.out.println("存入" + i + " 账上金额为:" + value); } int get(int i){ if(value > i) value = value - i; else{ i = value; value = 0; } System.out.println("取走" + i + " 账上金额为:" + value); return i; }}class Save implements Runnable{ private Account a1; public Save(Account a1){ this.a1 = a1; } public void run(){ while(true){ a1.put(100); } }}class Fetch implements Runnable{ private Account a1; public Fetch(Account a1){ this.a1 = a1; } public void run(){ while(true){ a1.get(100); } }}public class TestCommunicate { public static void main(String[] args) { Account a1 = new Account(); new Thread(new Save(a1)).start(); new Thread(new Fetch(a1)).start(); }}
0 0
- 4月17日,TestCommunicate,每日20行。
- 4月18日,TestCommunicate,每日20行。
- 4月19日,TestCommunicate,每日20行。
- 6月4日,每日20行。
- 3月17日,GridLayoutDemo,每日20行。
- 4月20日,TestVector,每日20行。
- 4月4日,Decode,每日20行。
- 3月4日,simple_window,每日20行。
- 4月1日,StringEqualTest,每日20行。
- 4月2日,StringEqualTest1,每日20行。
- 4月3日,CharCode,每日20行。
- 4月5日,StringBufferPass,每日20行。
- 4月6日,StringBufferModify,每日20行。
- 4月7日,RemoveHZ,每日20行。
- 4月8日,DemogetProperties,每日20行。
- 4月9日,GetCurrentTime,每日20行。
- 4月10日,MyThread,每日20行。
- 4月11日,MyThread,每日20行。
- JZOJsenior1667.【AHOI2009】中国象棋
- 计算各种图形的周长(接口与多态)
- Java中,&&与&,||与|的区别
- 第三方jar或者aar使用的minsdkversion 小于自己app的version解决办法
- windows引导ubuntu,使用easyBCD
- 4月17日,TestCommunicate,每日20行。
- HDU-5188-zhx and contest【01背包】
- 计算长方体、四棱锥的表面积和体积
- 如何使用sklearn中的SVM(SVC;SVR)
- HDU 1255 覆盖的面积(离散化+线段树)
- thinkphp安全问题总结
- InputStream和Reader(BufferedReader、InputStreamReader 、FileReader )的区别
- ZOJ1012-Mainframe 贪心策略
- unity基础UI-Button