Reading notes in Java using the coprocessor __java

Source: Internet
Author: User

In theory, the process can significantly increase the amount of concurrency that Java applications can support, and Java should now add such a feature to the JDK7.

Background knowledge

Today's operating systems support multitasking, multitasking can be done in multiple processes or multithreading.

Multi-task scheduling on the operating system using preemptive and cooperative two ways:

Preemption refers to the operating system to give each task a certain time slice, after the arrival of the time slice, such as the task is still not released on the CPU occupation, then the operating system will be forced to release, which is currently the way most operating systems;

The cooperative type refers to the operating system allocating the CPU according to the order of the tasks, which will occupy the CPU unless it is actively released during the execution of each task.

It is worth noting that once a task occupies the CPU, it can cause other tasks to "starve to death", so the operating system does not really fit in this way.


After talking about the operating system multitask scheduling method, to see how the usual program is to support high concurrency, one is typically given to the operating system of a multiple-process or multithreaded mechanism, each task occupies a process or a thread, when the task has IO wait action, the process or thread into the scheduled queue, This is the way most programs are currently taking, and the downside is that if you want to support high concurrency, you have to create a lot of processes or threads, and both processes and threads consume a lot of system resources. On the other hand, when a process or thread is created too much, the operating system takes a lot of time to switch between processes or threads, and switching actions need to be maintained and restored, which consumes a lot of system resources;

Another approach is that each task does not occupy a single process or thread, and when an IO wait action is required during the execution of a task, the task releases the process or thread it occupies so that other tasks can use the process or thread. The benefits of this approach can reduce the need for native process or thread trees, and because the operating system does not need to do process or thread switching, but rather to implement the task of switching, the cost will be lower than the operating system switching. And this way is the Coroutine way, also known as the coordination way.

I've seen this way in Erlang too, and the idea of this concept was also in the way of writing programs,

If you have this new feature in JDK7, it will be a good feature that will greatly improve Java performance.

And in this way, it will be very good to bypass the need to start too many threads to support the high concurrency bottlenecks, improve the Java application can support the concurrent volume.

There are two ways to introduce Scala and Kilim on the web, which is better than the current test on the web.

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.