background

Review “Java concurrent programming in action” this column, temperature and new knowledge. Because the column content is more, this article knowledge column simple introduction and review. By the way, the comments below for each class are also good.

Course objective

Help those who have mastered the basics of Java business development capabilities and are struggling with CURD every day but want to move up the technology ladder. Concurrency in Java is a great way to differentiate a Java engineer from a Java engineer, so a lot of big companies tend to favor people who have the ability to do it. In fact, 95% of the big companies’ jobs are not related to concurrency, but the 5% you don’t screw up.

Concurrency core problem

  • How to efficiently dismantle tasks and assign them to threads
  • Synchronization, how do threads work together
  • Mutually exclusive, ensuring that only one thread is allowed to access a common resource at a time

The main content

Theoretical basis

  • A major source of concurrency problems
    • Visibility issues caused by caching
    • Atomicity issues with thread switching
    • Order problems with compiler optimization
  • The Java memory model, the happens-before rule does not mean that the previous operation Happens Before the subsequent operation. What it really means is that the result of the previous operation is visible to the subsequent operation. Like two telepathic people, although thousands of miles apart, the mind of one person, the other can see. The happens-before rule is meant to ensure this “telepathy” between threads. A more formal statement is that the happens-before rules constrain compiler optimization behavior, allowing compiler optimization but requiring compiler optimization to follow the happens-before rule.
  • Java thread
  • Mutex basically covers all the theoretical knowledge of Java concurrency, and you can see the whole picture here.

Utility class

  • Lock & Condition
  • Read-write lock ReadWriteLock
  • CountDownLatch and CyclicBarrier, working with multiple threads
  • Concurrent container
  • Executor and thread pools
  • Atomic classes
  • The Future related (Future, CompletableFuture CompletionService)

The content of the introduction is very practical, no conspicuous ingredients, but each has in-depth details, lack of many knowledge shortcomings.

Concurrent mode design

  • Copy – on – the Write mode
  • The Worker Thread model
  • Producer-consumer model

Case analysis

The case also introduces Guava’s current limiter, Netty, Disruptory and HiKariCP.

Each chapter of the more core part of the code is analyzed, indeed, sink, see the essence.

reference

In this paper, a reference model concurrent Java programming of actual combat, time.geekbang.org/column/intr…