Phase 1 Language Basics + Advanced _1-3-Java language senior _05- anomalies and achieve multi-threaded Section 3 thread synchronization mechanism _2_ code is thread-safety issues _

Shared by multiple threads votes




Created is an implementation class, which spread to three threads. This ensures that votes on 100. Three threads to sell tickets

there have been repeated problems



optimization program, the program to sleep10 milliseconds, increase the probability of duplication

occurred vote -1. There is no duplicate tickets and tickets have emerged.









 

Guess you like

Origin www.cnblogs.com/wangjunwei/p/11260204.html