Java programming ideas Chapter 21 Concurrency

First, knowledge excerpt

  1, concurrent with the problem solved can be divided into "speed" and "design management" of two kinds.

  2, to improve concurrency is usually run in a single processor a program on the performance. 

    It sounds counterintuitive. If you carefully consider what you will find, the concurrent program overhead of running on a single processor is indeed larger than the order should have all parts of the program execution overhead, because it increases the so-called context switching cost (switching from one task to another a task).

    This problem is becoming somewhat different is blocked. If the program is a task because certain conditions outside the control of the thread (usually I / O) and lead can not continue, then we say that this task or thread blocked up. If no concurrent, the entire program will be stopped until the external conditions change. But if you use concurrent write

  Program, then when a blocking task, other tasks in the program can continue to perform, so the program can continue to maintain forward. In fact, from a performance standpoint, if the task is not blocked, the concurrent use on a single processor machine would not make any sense.

  3, the most direct way to achieve concurrency is to use the operating system level processes. The process is self-contained program runs in its own address space.

  4, the operating system will usually isolate processes from each other, so they will not interfere with each other, which makes it relatively easy to use programming process. On the contrary, as this system of concurrent Java will be used to share resources such as memory and I / O, so we write multithreaded programs for these basic difficulty lies in the coordination of resources between different threads driven tasks

  Use the source, so that these resources will not simultaneously access multiple tasks.

  5, Java preemptive threading mechanism, which means that scheduling mechanism will periodically interrupt thread to switch context to another thread, thereby providing each thread time slice, so that each thread is assigned to a reasonable number of time to drive its mission.

  6, a thread is a single sequence in the process of flow control, therefore, a single process can have concurrent execution of multiple tasks.

Guess you like

Origin www.cnblogs.com/mihasha/p/11148030.html