This will block the thread until all other threads have called the method, then they are released all at once.
这么做会引起阻塞,当所有线程都调用了这个方法后,便会同时释放所有线程。
Because the main thread is solely responsible for multiplexing between all clients, we cannot afford to allow it to block.
因为主线程单独负责所有客户机间的多路复用,因此我们不能让它阻塞。
With locking, if one thread attempts to acquire a lock that is already held by another thread, the thread will block until the lock becomes available.
使用锁定,如果一个线程试图获取其他线程已经具有的锁定,那么该线程将被阻塞,直到该锁定可用。
How can the operation request and response be decoupled so the thread of execution does not have to block until a response is received?
如何分离操作请求和响应,以使得在接收到响应之前不必阻塞线程的执行?
Any caller that attempted to pass a task to a pool thread would find the pool empty, and its thread would block while it waited for an available pool thread.
试图向池线程传递任务的调用者都会发现池为空,在调用者等待一个可用的池线程时,它的线程将阻塞。
When one thread is executing a synchronized block, any thread waiting to enter that block is stalled.
当一个线程正在执行一个同步块时,任何等待进入该块的线程都将被阻塞。
Synchronized methods and blocks allow a thread to lock an object on entry and unlock the object on exit (to the method or block).
同步的方法和代码块允许线程在入口处锁定对象并在出口处解锁(针对方法或代码块)。
This may not always be the desired approach, however, and it is likely that the reader thread might want to wait or block itself until the time data becomes available.
但是,这种做法不总是我们想要的,读线程很可能希望等待(即阻塞自身),直到有数据可用时为止。
Specifically, if everything is happening in a single thread, performing long operations such as network access or database queries on the UI thread will block the whole user interface.
特别是,如果把所有的事件都放在主线程中来处理,需要长时间来处理的事件比如网络访问或者数据库查询,会阻塞整个UI。
In blocking mode, a thread will block on a read or a write until the operation is completely finished.
在阻塞模式中,线程将在读或写时阻塞,一直到读或写操作彻底完成。
Specifically, if everything is happening in the UI thread, performing long operations such as network access or database queries will block the whole UI.
如果UI线程需要处理每一件事情,那些耗时很长的操作——诸如访问网络或查询数据库等——将会阻塞整个UI(线程)。
Number of blocks and total block time: the number of instances and total elapsed time when the thread was in a BLOCKED state while invoking a method or service.
阻塞数量和总阻塞时间:在调用某个方法或服务时,处于BLOCKED状态的线程的实例数量和总占用时间。
A shortcoming of the synchronous approach is that the consumer must wait while the service is performed — the consumer's thread must block while the service runs.
同步方法的不足之处在于,在执行服务时使用者必须阻塞——在服务运行时线程必须阻塞。
When a thread exits a synchronized block as part of releasing the associated monitor, the JMM requires that the local processor cache be flushed to main memory.
当线程为释放相关监视器而退出一个同步块时,J MM要求本地处理器缓冲刷新到主存中。
Because of the single thread model described above, it's vital to the responsiveness of your application's UI that you do not block the UI thread.
根据对以上单线程模式的描述,要想保证程序界面的响应能力,关键是不能阻塞UI线程。
The last point of interest for this section is the thread block times that are rolled up to the database level.
本节最后将介绍上升到数据库级的线程阻塞时间。
Block the worker thread and wait for the response.
阻塞工作线程并等待响应。
This was achieved by adding a general "catch-all" block in the Thread class.
这一目标是通过在thread类中添加一个通用的“catch - all”代码块来实现的。
Thread 1 exits the synchronized block and returns instance from the getInstance() method.
线程1退出synchronized块并从getInstance()方法返回实例。
The recipient can ask the Future to block until a result is ready, poll to see whether it's complete, cancel the computation, or check whether another thread has canceled it.
接收者可以要求Future阻止线程,直至一个结果就绪,检测查看它是否完成并取消计算指令,或检查是否有其他进程取消了它。
If necessary, a thread can block on the agent until its changes have been applied, or you can specify an action to be executed when the changes are applied.
如有必要,一个线程可以阻止agent,直至其更改被应用,或者您可以在应用变更时指定执行一个操作。
In addition, volatile variables (unlike locks) cannot cause a thread to block, so they are less likely to cause scalability problems.
此外,volatile变量不会像锁那样造成线程阻塞,因此也很少造成可伸缩性问题。
The synchronized keyword lets only one thread enter a code block at a time.
synchronized关键字每次仅允许一个线程进入代码块。
allows your thread to block - by calling f.get() - to ensure the network calls succeed, or go away by ignoring f altogether.
可以阻塞线程,再调用f.get()可以让网络调用继续进行或是忽略掉f。
When the first thread exits the synchronized block, the waiting thread enters and creates another Singleton object.
当第一个线程退出synchronized块时,等待着的线程进入并创建另一个Singleton对象。
Most programmers know that the synchronized keyword enforces a mutex (mutual exclusion) that prevents more than one thread at a time from entering a synchronized block protected by a given monitor.
大多数程序员都知道,synchronized关键字强制实施一个互斥锁(互相排斥),这个互斥锁防止每次有多个线程进入一个给定监控器所保护的同步语句块。
In case of an exception, the catch block simply called the exception publisher, then returned the executing thread back to the thread pool.
如果发生了异常,这个catch块只是简单地调用异常发布程序,然后将正在执行的线程返回到线程池中。
Using the Future object, the current thread can block to wait for the result
利用Future对象,当前线程可阻塞来等待结果
Then, one thread enters the synchronized block to initialize instance, while the other is blocked.
然后,一个线程进入synchronized块来初始化instance,而另一个线程则被阻断。
On the other hand, if the calling thread needs to be blocked for a specific time, then pthread_cond_timedwait is used to block the thread.
在另外一方面,如果调用线程需要被阻塞一段确定的时间,那么就可以使用pthread_cond _ timedwait来阻塞这个线程。
应用推荐