Java core Technology notes for busy people (10, concurrent programming)

Source: Internet
Author: User

This chapter highlights:

Runnable describes a task that can be executed asynchronously

Executor to include runnable instances in the execution plan

Callable describes a task that produces results

You can submit one or more callable instances to executorservice, and when these callable have execution results, merge the results

When multiple threads manipulate shared data without synchronization, the result is unpredictable

Parallel algorithms and thread-safe data structures are better than programming with lock mechanism

Parallel stream and array operations can automatically and safely run compute parallelism

Concurrenthashmap is a thread-safe hash table that allows atoms to update their elements

Atomiclong can be used as an unlocked shared counter, or if the thread is competitive, you can use Longadder

Lock ensures that only one thread executes the critical section at the same time

When an interrupt flag is set or an interruptedexception exception occurs, the Interruptible task should terminate. Long-running tasks should not block the program's UI, but progress and eventual updates need to appear in the UI thread

The Process class allows you to execute commands in a separate process and interact with the input, output, and error streams.

Java core Technology notes for busy people (10, concurrent 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.