1 Recommended Resources
Blog: Concurrent Programming Network-http://ifeve.com/java_multi_thread_programming_1_2/
Books: Java Concurrency programming Practice Http://vdisk.weibo.com/s/aP04X7rRcCoks
2 outline
Concurrent programs can improve multi-core processor utilization and speed up response. Even in a single-core scenario, concurrent programs can effectively improve performance. And concurrent programming corresponds to sequential programming, sequential programming can only be executed in order. When the program waits for resources to block, the entire program is also forced to wait. Concurrent programming can switch to another task when one task is blocked, effectively improving the performance of the program.
There are many ways to implement concurrent programming, such as multi-process, functional programming, multi-Threading. The process itself has a separate memory space and is able to run independently of other processes, so many people think of multiple processes as the only way to do concurrent programming. Functional programming is a programming paradigm with no side effects. Since the FP language does not contain any assignment statements, the value of the variable will never change once it is assigned. Moreover, the calling function will only calculate the result-no other effect will occur. Therefore, the FP language has no side effects. Java is a multi-threaded approach for concurrent programming, and threads are considered "lightweight processes." Shared memory between threads, thread creation, disappearance, and context switching are lightweight. However, the introduction of multithreading can lead to thread safety, risk of activity, and performance risk. If security means "nothing bad has happened", the failure of activity is a complementary aspect of "good things end up" and performance means that "good things happen Soon" "Java Concurrency programming practices."
Java Multithreaded outline
Callable interface and runnable interface differences:
Difference: 1Callable using the Call () method, runnable using the Run () method
The prototype of the 2.call method is public interface callable
{
V call () throws Exception;
} prototype of the Run method:
public interface Runnable
{
void call ();
}
Can be divided into two points:
The A.call method has a return value, and the Run method does not return a value
The B.call method can throw an exception that is handled, and the run method cannot throw an exception
The 3.Runnable interface is introduced by java1.1, and callable is a new java1.5.
Java Concurrency programming