Java multi-threaded and highly concurrent actual practice
Let's look at some of the highly concurrent multi-threaded concurrency manufacturers face questions, see if you can know the result of a few!
CPU primitive level (1) synchronized is how to achieve?
(2) no lock, tend to lock, lock lightweight, heavyweight lock What's the difference, how to upgrade?
(3) threads between communication with the machine process between communications, cross-machine process between communications, have what method?
(4) the following three services, how to use the thread pool:
- High concurrency, short task execution time business
- Concurrency is not high, long task execution time business
- High concurrency, long-time business execution of business
(5) spike system, how to shore up the 100W level TPS (Taobao up to 540,000 TPS)?
If only the usual CRUD experience, do not understand the multi-threaded and highly concurrent, face to face such questions, the probability of a large loss.
Java high concurrency frequently asked interview questions
- synchronized keyword bytecode primitive;
- The volatile keyword bytecode primitive;
- synchronized and volatile hardware level implementation;
- No lock, tend to lock, lock lightweight, heavyweight upgrade process locks;
- The basic concept of memory barrier;
- How the JVM specification requirements memory barrier;
- How to help java memory barrier hardware level to achieve high concurrency;
- Interview Question 3 (inter-thread communication) of eight kinds of solution;
Java multi-threading line Internet frequently asked interview questions
- Learning and thinking thread pool;
- Good and bad use of the thread pool;
- Why Ali manual recommends the development of a custom thread pool;
- Custom thread pool of best practices;
- Common thread pool types and application scenarios:
1)CachedPool
2)FixedThreadPool
3)ScheduledPool
4)WorkStealingPool
5)ForkJoinPool
- More cattle than the threads in a thread X, the measurement results show the power of the pressure shred;
Java multi-threading
Java multi-threading skills
- The concept and the advantages of multi-threaded processes and threads
- The use of multi-threading
- currentThread 0 method
- isAlive 0 method
- Methods sleep 0
- getId0 method
- Stop Thread
- Pause thread
- yie1d method
- Thread priority
- Daemon thread
Concurrent access to objects and variables
- synchroni zed synchronization method
- synchroni red sync block of statements
- volatile keyword
Inter-thread communication
- Waiting / notification mechanism
- Use join the
- Use of class ThreadLoca1
- The class uses Inheri tabl eThreadLocea1
Lock of use
- Use Reentr antLock class
- Use Reentr antReadWr iteLock class
Timer Timer
- Use the timer Timer
Singleton and multithreading
- Load Now / "starving mode."
- Lazy loading / "lazy mode"
- Built implemented using static class Singleton
- Serialization and deserialization achieve singleton
- Stati e implemented using code blocks Singleton
- Enum enumeration data type using single-mode embodiment
- Improve the use enum enumeration achieve Singleton
Supplements Supplement
- State of the thread
- Thread Group
- The thread has orderliness
- Simpl eDateP ormat non-thread-safe
- Exception handling thread appears
- Handling exceptions in the thread group
- Delivery thread exception handling
Java combat high concurrency
Basis - structuring concurrent applications - activity, performance and testing - Advanced Topics
Due to copy too long, Xiao Bian here is not to explain to you, show you in the form of screenshots, to learn high concurrency, multi-threaded, distributed real friends who are interested can be private letter I replied , "architecture books " get a free, easy to organize another, feel this article help you, take the trouble to help forward out to see more friends
Basics
- Thread safety
- Shared objects
- Composite object
- Fundamental building blocks
Thread safety
- What is the thread safety
- Atomicity
- Race Conditions
- Example: initializing the delay of race conditions
- Complex operation
- Locking mechanism
- Built-in lock
- Reentrant
- Use locks to protect state
- Activity and Performance
Shared objects
- Visibility
- Failure Data
- Non-atomic operation 64
- Locking and Visibility
- Volatile variables
- Release and escape
- Thread closed
- Ad-hoc thread closed
- Stack closed
- ThreadLoca1 class
- Invariance
- Final field
- Example: Using Volatile release type immutable
- Security release
- Incorrect release: the correct object is destroyed
- Immutable objects and initialize security
- Common mode security release
- The fact immutable objects
- Variable Object
- Secure shared object
Composite object
- Design thread-safe class
- Collect synchronization requirements
- State-dependent operation
- State ownership
- Examples closed
- Java monitor mode
- Example: Vehicle Tracking
- Thread safety commission
- Example: based on vehicle delegate tracker
- Become an independent state in
- When the commission fails
- Published underlying state variable
- Example: Release Status vehicle tracker
- To add functionality to an existing thread-safe classes
- Client locking mechanism
- combination
- The synchronization strategy documented
Fundamental building blocks
- Synchronization containers
- Synchronization issues container class
- Iterators and Concurr ent-Modi ficatExcepti on
- Hide iterator
- Concurrent containers
- Concurr entHashMap
- Additional atomic operation Map
- CopyOnYri tar ayList
- Blocking queue and producer-consumer model
- Example: Desktop Search
- Serial thread closed
- Deque adhesion work level
- Blocking method and interrupt method
- Synchronization tools
- Lockout
- Future anD ask
- signal
- Fences
Structured concurrent applications
- Task Execution
- Cancel and close
- Use the thread pool
- The graphical user interface application
Task Execution
Cancel and close
Use the thread pool
The graphical user interface application
Activity, performance and testing
- Avoid dangerous activity
- Performance and scalability
- Testing concurrent programs
Avoid dangerous activity
Performance and scalability
Testing concurrent programs
Advanced Topics
- Explicit lock
- Build custom synchronization tool
- Varying in synchronization with the atoms nonblocking
- Java Memory Model
Explicit lock
- Lock与Keentr antLock
- Polling time lock with lock
- Interruptible lock acquisition operation
- Non-locking block structure
- Performance considerations
- Fairness
Build custom synchronization tool
- State-dependent management
- Example: delivery failure precondition to the caller
- Example: Sleep achieved by polling and
- Simple obstruction
- Conditions queue
- Conditions queue
- Conditions predicate
- Wake up early
- Loss of signal
- Notice
- Example: Latches
- Security issues subclass
- Packaging Condition queue
- Entrance and exit protocol agreement
- Explicit Condi ti on objects
- Symchr oni zer analysis
- Abstr actQueuedSyn.chr oni acids
- Java. Util. Concurr ent synchronizer class AQS
- Reentr antLock
- Semsphor e and CountDownLatch
- FutureTask
- Reentr antKeadKri teLock
Varying in synchronization with the atoms nonblocking
- Lock与Keentr antLock
- Polling time lock with lock
- Interruptible lock acquisition operation
- Non-locking block structure
- Performance considerations
- Fairness
- Selecting between synchu oni red and Reentr antLock
- Read - write lock
Java Memory Model
- What is the memory model, why you need it
- Platform memory model
- Reordering
- Java Memory Model Introduction
- With synchronous
- release
- Unsafe release
- Safe release
- Security initialization mode
- Double-checked locking
- Security during initialization
distributed
Due to copy too long, Xiao Bian here is not to explain to you, show you in the form of screenshots, to learn high concurrency, multi-threaded, distributed real friends who are interested can be private letter I replied, "architecture books "get a free, easy to organize another, feel this article help you, take the trouble to help forward out to see more friends