问题是这样的.我在
Windows 7上使用JDK 6.0,并尝试使用信号量作为解决同步问题的机制.它工作得很好,但我试图避免忙于等待我的问题.
我只想问一下java文档并省去了麻烦,但文档是这样的:
Acquires the given number of permits from this semaphore,
blocking until all are available, or the thread is interrupted.
Acquires the given number of permits, if they are available,
and returns immediately, reducing the number of available permits
by the given amount.
If insufficient permits are available then the current thread
becomes disabled for thread scheduling purposes and lies dormant
也就是说,文档似乎暗示了两个答案.哪一个是正确的?