2022
04-20
04-20
Java多线程下解决数据安全问题
目录同步代码块同步方法lock锁同步代码块基本语句synchronized(任意对象){操作共享代码}代码示例publicclassSellTicketimplementsRunnable{privateinttickets=100;privateObjectobject=newObject();@Overridepublicvoidrun(){while(true){synchronized(object){if(tickets>0){try{Thread.sleep(100...
继续阅读 >