Java多线程处理
Java多线程处理(中文5400字,英文3500字)
摘要
利用对象,可将一个程序分割成相互独立的区域。我们通常也需要将一个程序转换成多个独立运行的子任务。
象这样的每个子任务都叫作一个“线程”(Thread)。编写程序时,可将每个线程都想象成独立运行,而且都有自己的专用CPU。一些基础机制实际会为我们自动分割CPU的时间。我们通常不必关心这些细节问题,所以多线程的代码编写是相当简便的。
这时理解一些定义对以后的学习狠有帮助。“进程”是指一种“自包容”的运行程序,有自己的地址空间。“多任务”操作系统能同时运行多个进程(程序)——但实际是由于CPU分时机制的作用,使每个进程都能循环获得自己的CPU时间片。但由于轮换速度非常快,使得所有程序好象是在“同时”运行一样。“线程”是进程内部单一的一个顺序控制流。因此,一个进程可能容纳了多个同时执行的线程。
英文原文
Java multi-threaded processing
Summary
Using object, a program can be divided into separate areas. We usually also need a program into multiple independent subtasks run. [资料来源:http://doc163.com]
Each sub-task like this are called a "thread" (Thread). Preparation process, each thread can be imagined as an independent operation, and has its own dedicated CPU. Some basic mechanisms for us to automatically split the actual CPU time. We usually do not care about these details, so write multithreaded code is fairly simple.
Then understand some definitions for future learning ruthless help. "Process" refers to a "self-contained" in running the program, with its own address space. "Multi-tasking" operating system can simultaneously run multiple processes (programs) - but actually it is because the CPU time-sharing mechanism, so that each process can obtain its own CPU cycle time slice. However, due to the rotation speed is very fast, so that all procedures seems to be in the "simultaneous" run the same. "Threads" is the process of an internal single sequential flow of control. Therefore, a process may accommodate multiple simultaneous execution threads. [资料来源:http://www.doc163.com]