Intro to Concurrency - raisercostin/software-wiki GitHub Wiki

These problems are the worst kind: are hard to debug, understood and solve. To attack them you should understand some concepts like:

  • pessimistic lock - lock a resource and everyone waits to be unlocked
  • optimistic lock - on save you check the last version of the data (this is a versioning/dirty mechanism)
  • test-and-set
    • image
  • others: multi-threading, parallelism, threads, thread locals, race conditions, locks, deadlocks, live-locks, thread safety, concurrency, mutex, semaphores, barrier, locks, latches, monitors, critical sections, rendezvous, actors, atomic operations, exclusion zone, immutability, mutual exclusion, re-entrancy, transactions, isolation level, ACID, deterministic and non-deterministic algorithms, synchronous/asynchronous operations, sync/async blocks, handlers, callbacks, Futures, Promises, Streams, ReactiveStreams

Growth Reading List

  • Working Effectively With Legacy Code
  • Domain Driven Design
  • Refactoring: Improving the Design of Existing Code
  • NoSQL Distilled
  • Effective Java
  • Java Puzzlers: Traps, Pitfalls, and Corner Cases
  • Java Concurrency in Practice
  • Concurrent Programming in Java: Design Principles and Pattern
  • Beautiful Code: Leading Programmers Explain How They Think
  • Java Concurrency

Concepts

Threads vs Green Threads

https://openjdk.java.net/jeps/425

reentrant

In the same thread you're not allowed to recall the same method. A() -calls-> B() -> A() or A() -> B() or in general you're not allowed to A() -> ... -> A(). This means that most probably global things are stored from the function. To be reentrant the function should not store anything (see tailrec) or only store things on the stack.

  • For example An XPath expression is not thread-safe and not reentrant. In other words, it is the application's responsibility to make sure that one XPathExpression object is not used from more than one thread at any given time, and while the evaluate method is invoked, applications may not recursively call the evaluate method.

volatile

synchronized

local copy

AtomicRef

Comparisons

Resources

Java

More

(by antonia)