Sometimes it is perfectly sensible to spawn a new thread for each new task.
有时,为每个新任务生成一个新线程是十分明智的。
While a thread is running, either uploading or downloading, you can query it to check on its status to provide the user with feedback (e.g. a progress bar).
当一个线程在运行的时候,不管是上传还是下载,你可以查询进程状态并且给用户一个反馈(例如一个进度条)。
A general solution for the problem above is to have each user thread hold a locale variable by passing the variable to the user thread during its construction.
对于以上问题通用的解决方法,是通过在构造变量期间将其传递给用户线程,来让每一个用户都有一个场所变量。
As mentioned above, sometimes it is perfectly sensible to spawn a new thread for each new task.
如同上面所提到的,有时,为每个新任务生成一个新线程是十分明智的。
If the CANCEL statement names a program that is active to any thread, the execution fails.
如果cancel语句指定了一个程序,并且该程序对于任意线程都是活跃的,那么执行将失败。
A significant risk in all kinds of thread pools is thread leakage, which occurs when a thread is removed from the pool to perform a task, but is not returned to the pool when the task completes.
各种类型的线程池中一个严重的风险是线程泄漏,当从池中除去一个线程以执行一项任务,而在任务完成后该线程却没有返回池时,会发生这种情况。
A simple approach to this is to just generate a random number when a thread is spawned and prepend that number to all output lines.
为此,一种简单的方法就是仅在派生某个线程时才生成一个随机数,并将该随机数追加到所有输出行上。
A better approach is to start a timer, and have timer poke the event thread every so often to go look at the staging area for updates.
更好的方法是启动计时器,并且使计时器不时地提醒事件线程去查看中间区域,以寻找更新。
Usually, the main use of a semaphore is to synchronize a thread?s action with other threads.
通常,信号的主要用途是同步某个线程与其他线程的动作。
The message listener service is configured to use a thread pool that has the maximum threads property set to 4.
消息侦听器服务配置为使用最大线程属性设置为4的线程池。
The interrupted status is initially false; when a thread is interrupted by some other thread through a call to Thread.interrupt(), one of two things happens.
中断状态初始时为 false;当另一个线程通过调用 Thread.interrupt() 中断一个线程时,会出现以下两种情况之一。
A single arrow indicates a thread contention: One thread is waiting for another thread to release a lock.
一支单独的箭头指出一个线程竞争:一个线程正在等候另一个线程释放一个锁。
Each routine represents a separate "thread of execution" and is referred to as a task.
每一个程序表现得像分开的“执行的线程”并且被看作是一个任务。
However, because there is only one AWT thread, it is undesirable to execute tasks in the AWT thread that may take a perceptible amount of time to complete.
然而,由于只有一个AWT线程,因此要在AWT线程中执行任务可能要花费相当长时间才能完成,这是不可取的。
A thread is allocated to handle shutdown events.
一个线程被分配为处理关机事件。
Sometimes, it is very difficult to make a class thread-safe without compromising its functionality, ease of use, or performance.
有时,要在不影响类的功能、易用性或性能的情况下使类成为线程安全的是很困难的。
Once the class has been resolved, the original code location is modified in a thread-safe way to access the static field's address directly because that address is then known.
类一旦被解析,就会以一种线程安全的方式修改原始代码位置以便直接访问静态字段的地址,因为此时已获知该地址。
Because some processing can take a long time, we need multiple processing threads per production line to make sure that a thread is always available to work on the latest measurement.
由于某些处理可能要占用较长的时间,因而需要为每条生产线使用多个处理线程,确保总有一个线程能来处理最新的度量结果。
When one thread is executing a synchronized block, any thread waiting to enter that block is stalled.
当一个线程正在执行一个同步块时,任何等待进入该块的线程都将被阻塞。
Instead, interruption is a way of politely asking another thread to stop what it is doing if it wants to, at its convenience.
相反,中断是礼貌地请求另一个线程在它愿意并且方便的时候停止它正在做的事情。
'There is a variegated thread that goes purple to white then back to purple,' he said.
“有一种杂色线,它的颜色从紫色变成白色,然后又变回紫色”,他说。
They all output the same value illustrating that this is a thread-safe generic way to create singletons.
所有线程都返回相同的值,这说明这是一个线程安全的使用泛型来实现的单态模式。
What you really need is a way to put a thread to sleep while it waits for some condition to be met.
真正需要的是这样一种方法,当线程在等待满足某些条件时使线程进入睡眠状态。
However, to avoid potentially severe thread starvation between applications, it is possible to configure a thread pool to allow thread allocation beyond maximum thread size.
不过,为避免应用程序之间发生严重的线程供给不足问题,可以配置一个线程池,允许线程的分配超出最大线程大小。
Another possibility is to fork a separate low-priority thread during startup to perform initialization when the system is idle, although this choice requires more care to handle synchronization.
还有一种可能是在启动时派生一个单独的低优先级的线程,当系统空闲时再去完成初始化,不过这种方法需要特别注意处理好同步。
A Runnable is submitted to a custom thread pool.
将可运行线程提交到自定义线程池。
In a multiprocessing environment, the processing time for a thread is related to the availability of system resources and synchronization with other threads.
在多处理环境中,线程的处理时间与可用系统资源以及与其他线程的同步有关。
A first-pass solution to this is to store up encoded messages while a background thread tries to upload them.
初步的解决方案是,当后台线程试图上传编码消息时对这些消息进行存储。
Each processor on the CPU has its own CSA (current save area) pointer that points to the MST that is to be used when a thread or interrupt handler is interrupted or swapped due to context switch.
CPU上的每个处理器都拥有自己的CSA(当前保存区)指针,指向当线程或中断处理程序由于上下文切换而被中断或交换时使用的MST。
The system detects that the P3 thread is holding a lock required by the P1 thread and elevates its priority to P1 until the lock is released.
如果系统检测到P 3线程正在持有一个P 1线程需要的锁,则会把P 3线程的优先级置为P1,直到它释放了锁。
应用推荐