唯一的主要差别,如上所述,是这些阻塞读和写可以被其它线程中断。
The one major difference, mentioned above, is that these blocking reads and writes can be interrupted by other threads.
清单6展示了一个方法,该方法等待一个阻塞队列,直到队列中出现一个可用项目,而不管它是否被中断。
Listing 6 shows a method that waits on a blocking queue until an item is available, regardless of whether it is interrupted.
接着,它开始等待,直到建立了一个新的连接,或者另一个线程将它唤醒,或者另一个线程将原来的阻塞线程中断。
It then waits until a new connection is made, another thread wakes it up, or another thread interrupts the original blocked thread.
应用推荐