universal thread counter 通用纱线支数计
Note that all the methods, even get(), need to be synchronized for the class to be thread-safe, to ensure that no updates are lost, and that all threads see the most recent value of the counter.
注意所有方法,甚至需要同步 get(),使类成为线程安全的类,从而确保没有任何更新信息丢失,所有线程都看到计数器的最新值。
After the counter has been incremented, the invoking process does a wait , which leads to the calling thread getting blocked.
在计数增加之后,调用进程执行wait,这导致调用进程受阻塞。
For example, you could have a global counter, and once it reaches a certain count a thread activates.
比如你可以建立一个全局计数器,一旦它到达某个值一个线程就被激活。
应用推荐