线程模式是影响组件运行性能,资源消耗的重要因素。
Thread model was one of the important factors that affect the performance and the consumption of resources of its component.
根据对以上单线程模式的描述,要想保证程序界面的响应能力,关键是不能阻塞UI线程。
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.
在我的公司,我们使用无线程的方法,因为我没有足够的资源和人力处理线程模式。
In my company, we went for the non threaded way, because I just don't have the resources and disposition to cope with the threaded.
但不幸的是,上面的代码违背了UI线程的单线程模式:Android UItoolkit不是线程安全的,所以对UI的操作都应该在主ui线程中进行。
Unfortunately, it violates the single-threaded model for the UI: the Android UI toolkit is not thread-safe and must always be manipulated on the UI thread.
这对于以服务器模式运行很多线程的环境很有利,因为这种环境必要时可以在多个连接上使用不同的优化目标。
This allows environments that run with many threads in server mode to have the benefit of running with distinct optimization goals across the multiple connections, if desired.
因为根据设计它是线程安全的,创建它之后可以把它缓存在一个公共静态最终变量中,或者包装在单实例模式中以供以后访问。
Since it is thread safe by design, you might cache it in a public static final variable, or wrap it in a singleton pattern after creation for later access.
在非阻塞模式中,线程将读取已经可用的数据(不论多少),然后返回执行其它任务。
In nonblocking mode, the thread will read whatever amount of data is available and return to perform other tasks.
现有的几个线程池实现可以很好地与此模式一起使用。
Several thread pool implementations exist that will work fine with this model.
在此实例中,我并没有针对其他与此模式相关的问题,如保持同步以确保线程安全。
In this example, I don't focus on other issues related to this pattern, such as synchronization to make it thread safe.
在两种编程模式中,线程可以由不同的应用程序重用。
In both programming models, threads can be reused by different applications.
因为上面介绍的模式非常有效,所以可以通过连接附加线程池和队列来进行扩展,这是相当简单的。
Because the pattern demonstrated above is so effective, it is relatively simple to extend it by chaining additional thread pools with queues.
它最简单的使用模式便是作为一个线程安全的队列,并且在队列为空时阻塞消费者。
In its simplest mode it ACTS as a thread-safe queue in which consumers are blocked while the queue is empty.
细粒度组件还趋向于在同一执行线程上交互,从而减少通信量较多的交互模式的开销。
Fine-grained components also tend to interact on the same thread of execution, which reduces the overhead of a chatty interaction pattern.
它显示线程的内核模式栈跟踪。
在这种模式下,将依次完成各个处理过程,并将结果统一返回给消费线程。
This completes all the processing at once and then turns over all the resources to the consumer thread.
在阻塞模式中,线程将在读或写时阻塞,一直到读或写操作彻底完成。
In blocking mode, a thread will block on a read or a write until the operation is completely finished.
每个线程的逻辑遵循执行 >等待下一周期 > 执行 > 等待下一周期……的模式。
The logic for each thread follows the model of execute>wait for next period>execute>wait for next period, and so on.
基于新的执行注释,用户能清楚地规定其网络处理器中的回调函数应该以单线程的模式执行还是多线程的模式执行。
Based on the new execution annotations the user can define if the call back methods of his network handler should be executed in single threaded mode or multithreaded mode.
工作站模式/并发执行,也叫并发GC-工作流程与非并发GC基本相似,但不会在整个清理周期挂起其他托管线程。
Workstation/Concurrency ON, also called Concurrent GC. – Like in the previous scenario, but the GC does not suspend the managed threads for the entire period when it reclaims unused memory.
虽然有许多很好的联机资源详细说明了线程API,但本文尝试提供一些实际的示例,以说明一些常见的线程使用模式。
There are many great resources online that document the threading API, but this article attempts to provide practicle examples of common threading usage patterns.
另外,由于分数更新逻辑遵循check - then -act模式,因此可能出现两个线程“争夺”更新最高分,从而导致难以预料的结果。
Further, because the score-updating logic follows the check-then-act pattern, it is possible for two threads to "race" to update the high score, with unpredictable results.
在Python中使用线程时,这个模式是一种很常见的并且推荐使用的方式。
This pattern is a very common and recommended way to use threads with Python. The steps are described as follows.
Participant模式可以将简单的方面转换为更复杂的方面,如负责事务管理、线程安全、安全性等方面。
The Participant pattern lets you make the transition from simple aspects to more complex ones such as those for transaction management, thread safety, security, etc.
用来对这些线程进行初始化和销毁的代码都在 #ifdef INTR_SIMULATION 之下,这样在普通模式下编译的代码不会影响驱动程序对象的发行版本。
The code to initialize and destroy the threads will be under #ifdef INTR_SIMULATION, so that under normal compilation this code will not affect the release version of the driver object.
授权支持:可以处理各种授权方式,不管你是使用Windows验证、线程安全主体、ASP.NET基于角色的安全模式或者你自己自定义的。
Authorization Support: Handled a variety of ways whether you use Windows authentication, thread principals, ASP.NET role-based security or your own.
当操作系统检测到一个线程空闲时,把对硬件的控制权交还给系统管理程序,这会使线程进入 nap模式。
The way it works is that the OS detects when a thread is idle and then gives control of the hardware back to the hypervisor, which puts the thread into nap mode.
如果多个箭头显示一个环形的锁请求模式—由于它们正在相互等候其它线程释放锁,所以线程彼此阻止运行—结果就形成了一个死锁。
If multiple arrows show a circular lock-request pattern — threads prevent each other from running because they are waiting for each other to release a lock — then you have a deadlock.
尽管这个基本模式比较简单,但可以通过将队列和线程池连接在一起,以便将这个模式用于解决各种各样的问题。
While this basic pattern is relatively simple, it can be used to solve a wide number of problems by chaining queues and thread pools together.
这种模式能被很多行业运用,从出版到在线程序到信息工作者等等(甚至博客)!
This model can be applied to many businesses, from publishing to online apps to information workers and more ( even blogging!).
这种模式能被很多行业运用,从出版到在线程序到信息工作者等等(甚至博客)!
This model can be applied to many businesses, from publishing to online apps to information workers and more ( even blogging!).
应用推荐