|
此文章由 kawara 原创或转贴,不代表本站立场和观点,版权归 oursteps.com.au 和作者 kawara 所有!转贴必须注明作者、出处和本声明,并保持内容完整
原帖由 cdfei 于 2010-10-19 16:55 发表 ![](http://www.oursteps.com.au/bbs/images/common/back.gif)
多线程和多核完全是两回事,以前单核CPU一样跑多线程的程序,起码windows95就是多线程了。
多核如何协同工作,看看intel和AMD的产品介绍就知道了。
不会吧。你也是net programmer 么?
在Java里,一个线程只能某一时刻只能分配在一个Cpu core上,并发线程多了,自然就能利用更多的core了。并不需要看硬件说明。
Multithreading: Advantages/Uses
Multithreading as a widespread programming and execution model allows multiple threads to exist within the context of a single process. These threads share the process' resources but are able to execute independently. The threaded programming model provides developers with a useful abstraction of concurrent execution. However, perhaps the most interesting application of the technology is when it is applied to a single process to enable parallel execution on a multiprocessor system.
This advantage of a multithreaded program allows it to operate faster on computer systems that have multiple CPUs, CPUs with multiple cores, or across a cluster of machines — because the threads of the program naturally lend themselves to truly concurrent execution. In such a case, the programmer needs to be careful to avoid race conditions, and other non-intuitive behaviors. In order for data to be correctly manipulated, threads will often need to rendezvous in time in order to process the data in the correct order. Threads may also require mutually-exclusive operations (often implemented using semaphores) in order to prevent common data from being simultaneously modified, or read while in the process of being modified. Careless use of such primitives can lead to deadlocks.
Another advantage of multithreading, even for single-CPU systems, is the ability for an application to remain responsive to input. In a single threaded program, if the main execution thread blocks on a long running task, the entire application can appear to freeze. By moving such long running tasks to a worker thread that runs concurrently with the main execution thread, it is possible for the application to remain responsive to user input while executing tasks in the background.
http://en.wikipedia.org/wiki/Thr ... :_Advantages.2FUses |
|