homework 4 Version 0 |
|
👤 Author: by 1842906413qqcom 2019-10-07 03:31:11 |
When buying cinema tickets online, many people can buy tickets at the same time, but the tickets are limited on that day.If there is no synchronization, the problem arises: two people are buying tickets at the same time, but there is only one ticket left, and two threads will view the remaining tickets and make the purchase at the same time.The number of votes exceeded the limit.If you implement synchronization, this will not happen.When a thread to access a variable, or check a variables, these variables related to any other threads are locked, so that the last remaining tickets only by a user thread lock, and the other threads are waiting in line to be unlocked, this means that the variables associated with the thread is not protected by any other threads, in addition to the currently executing thread.
Please login to reply. Login