2013年11月14日星期四

Multithreaded Programming

In a thread class can start multiple threads, which started when they perform the same way, if you want to perform more than one method , it is necessary to write and create multiple threads started classes .
I doubt since a thread class to start multiple threads execute methods are the same , in this case in which the significance of multi-threaded programming , do not understand . Which god knows next to explain to the younger , be grateful !
------ Solution ---------------------------------------- ----
1 a chef one the pot , 5 minutes fry two dishes
1 two chefs the pot , 5 minutes fried three dishes

Got it ?
------ Solution ---------------------------------------- ----
http://www.blogjava. net/junjie/archive/2009/03/01/257223.html

------ Solution ------------------------------------ --------
multithreading can be understood , that is , if you want to perform a lot of ways , the normal programming of these methods was performed sequentially , the first execution is over, the second before it is implemented . The significance of using multiple threads , open multiple threads , each thread executes a method, which multiple threads ( ie corresponding to the multiple methods ) will be executed concurrently , as a floor, say, can improve performance, increase processing speed .
------ For reference only ------------------------------------ ---
landlord you can not doubt the significance multithreading ah
You should preemptive multithreading mode of operation has doubts fishes
------ For reference only -------------------- -------------------
each ticket window all have the same ticket , why so many wickets ? because it can speed up the process , to avoid bottlenecks
------ For reference only ---------------------------- -----------

multithreading to improve efficiency is a prerequisite .
From a macro perspective of multiple threads simultaneously . However, microscopic , thread execution is to take up the cpu time slice , which is a time can only perform one task .

If you just let the CPU to perform calculations , and now the computer is sharing processing , single-threaded and multi-threaded efficiency is almost the same.
Multithreading efficiency
situation is , for example, need to wait for a user response or condition IO .
give Liezi , a ping applet. From URL 192.168.1.1 to 192.168.1.255, cycle ping, assuming Each URL ping fails, the computer waits 3 seconds timeout .
If you use a single-threaded , you need 255 * 3 seconds. If you are using C # thread pool or 4.0 parallel computing , it will save time for about 10 times .
------ For reference only -------------------------------------- -
open multiple threads to handle the same business logic can improve the business logic processing speed.
------ For reference only -------------------------------------- -
multiple threads execute the same way, really I do not know the meaning of multi-threading , and the efficiency is not necessarily higher than the single-threaded .
------ For reference only -------------------------------------- -
burst Antiaris

没有评论:

发表评论