Java Concurrency programming

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.