• 第二线程经历同样的过程。

    The second reader thread did an encore.

    youdao

  • 对于阻塞队列只有线程需要队列没有数据等待

    In a blocking queue, only the reader thread needs to wait when there is no data in the queue.

    youdao

  • 因此最后两个线程等待条件变量互斥锁没有锁住。

    Therefore, at the end of it all, you now have two reader threads, both waiting on the condition variable, and the mutex is unlocked.

    youdao

  • 因此唤醒线程之后,要确认列表然后继续处理

    Hence, after waking up the reader thread, verify that the list is not empty, and then proceed.

    youdao

  • 队列时候,线程现在并不抛出异常而是条件变量阻塞自身

    Instead of throwing an exception when the queue is empty, the reader thread now blocks itself on the condition variable.

    youdao

  • 如果超时时间段结束时还没有唤醒读线程需要唤醒自身释放互斥锁。

    If not awake otherwise, at the end of the timeout, the reader needs to wake itself up and release the mutex.

    youdao

  • 目前如果线程试图没有数据队列数据,仅仅抛出异常继续执行。

    So far, if a reader thread wanted to read data from a queue that had no data, you just threw an exception and moved on.

    youdao

  • 接下来线程需要确保(第二检查)等待条件变量时间超过指定超时时间

    Next, the reader thread needs to ensure (and this is the second check you perform) that it does not wait on the condition variable any more than the specified timeout period.

    youdao

  • 这么会唤醒所有等待条件变量_ cond线程读线程现在隐式地争夺互斥

    Doing so awakens all the reader threads that were waiting on the condition variable _cond; the reader threads now implicitly compete for the mutex lock as and when it is released.

    youdao

  • 但是这种做法总是我们要的,线程可能希望等待(阻塞自身),直到数据可用为止。

    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.

    youdao

  • 如果超时之前线程唤醒,pthread_cond _ timedwait返回0

    If the reader thread is awakened before the timeout, the return value from pthread_cond_timedwait will be 0.

    youdao

  • 第一线程互斥锁,发现队列的,然后 _cond 上阻塞自身,这会式地释放互斥锁。

    The first reader thread locked the mutex, realized that the queue is empty, and blocked itself on _cond, which implicitly released the mutex.

    youdao

  • 操作系统调度程序决定哪个线程获得互斥控制权—通常,等待时间最长线数据

    The operating system scheduler determines which thread gets control of the mutex next-typically, the reader thread that has waited the longest gets to read the data first.

    youdao

  • 如果队列了,线程等待_ wcond条件变量线程队列中取出数据之后需要通知所有线程

    If the queue is full, the writer thread waits on the _wcond condition variable; the reader thread will need a notification to all threads after consuming data from the queue.

    youdao

  • 显然如果使用原版/,那么按照标准锁的用法使用这个自旋锁,区分读线程线程

    Obviously, if your use of the lock is reader/writer in nature, this spinlock should be used over the standard spinlock, which doesn't differentiate between readers and writers.

    youdao

  • 这个函数与pthread_cond_wait相似但是第三参数绝对时间,到达这个时间时线程自愿放弃等待

    This function is similar to pthread_cond_wait, except that the third argument is the absolute time value until which the reader thread is willing to wait before it gives up.

    youdao

  • 尽管使用pthread_cond_signal不会损害阻塞队列功能,但是可能导致某些线程等待时间过长。

    Although the functionality of the blocking queue is not compromised with this choice, use of pthread_cond_signal could potentially lead to unacceptable wait times for some reader threads.

    youdao

  • 线程释放一个之后,另一个读线程随后获取了同一个锁。本质上,线程释放锁时会将强制刷新工作内存中的脏数据到主内存中,获取一个锁将强制线程装载(或重新装载)字段

    In essence, releasing a lock forces a flush of all writes from working memory employed by the thread, and acquiring a lock forces a (re) load of the values of accessible fields.

    youdao

  • 唯一主要差别如上所述,这些阻塞可以其它线程中断

    The one major difference, mentioned above, is that these blocking reads and writes can be interrupted by other threads.

    youdao

  • 因为映射典型存取操作会改变顺序如果多个线程可以映射表应该同步存取操作。

    Because the typical read-access of a map changes the order, if multiple threads could be reading from the map, you should synchronize access.

    youdao

  • 释放J VM结构操作gc线程一种安全形式处理这些结构;部分更新的结构进行操作可能导致不可预测的行为冲突

    The act of releasing JVM structures lets the GC thread process these structures in a safe fashion; reading and writing to partially updated structures can cause unexpected behavior and crashes.

    youdao

  • 阻塞模式中,线程时阻塞,一直或写操作彻底完成

    In blocking mode, a thread will block on a read or a write until the operation is completely finished.

    youdao

  • 理想情况下多个线程不能同时访问同一数据不复存在,死则会自动监测处理

    Ideally no two threads can try to modify the same piece of data at the same time, dirty reads are not possible, and deadlocks are automatically detected and handled.

    youdao

  • 没有同步时如果线程另外一个线程正在写变量线程看到过时数据

    In the absence of synchronization, if one thread writes to a variable and another thread reads that same variable, the reading thread could see stale, or out-of-date, data.

    youdao

  • 如果线程一个共享资源中修改或者一个,它必须获取

    If a thread wishes to modify or read a value from a Shared resource, the thread must first gain the lock.

    youdao

  • 一开始线程,从另一个结束想法使事情变慢因为寻找时间杀了

    But your idea of having one thread reading from the beginning and another reading from the end will make things slower because seek time is going to kill you.

    youdao

  • 如果一个线程处于可升级模式并且没有任何线程等待进入模式,那么任意数量线程可以进入模式,即使有线程在等待进入可升级模式。

    If a thread is in upgradeable mode, and there are no threads waiting to enter write mode, any number of other threads can enter read mode, even if there are threads waiting to enter upgradeable mode.

    youdao

  • 如果一个线程处于可升级模式并且没有任何线程等待进入模式,那么任意数量线程可以进入模式,即使有线程在等待进入可升级模式。

    If a thread is in upgradeable mode, and there are no threads waiting to enter write mode, any number of other threads can enter read mode, even if there are threads waiting to enter upgradeable mode.

    youdao

$firstVoiceSent
- 来自原声例句
小调查
请问您想要如何调整此模块?

感谢您的反馈,我们会尽快进行适当修改!
进来说说原因吧 确定
小调查
请问您想要如何调整此模块?

感谢您的反馈,我们会尽快进行适当修改!
进来说说原因吧 确定