This is a complete Java concurrency collation note, which records some of my experiences and experiences in recent years of learning Java concurrency.
J.U.C Overall understanding
Atomic Operation Part 1 starting from Atomicinteger
Atomic Operation Part 2 array, atomic operation of the reference
Atomic Operati
1. Several important concepts about high concurrency
1.1 Synchronous and asynchronous
First of all, synchronous and asynchronous refers to the function/method invocation aspect.
Obviously, the synchronous call waits for the return of the method, and the asynchronous call returns instantaneously, but the instant return of the asynchronous call does not mean that your task is done, and he will continue the task in the background with a thread.
1.2
? In fact, there is no difference in the cost of process and thread creation under Linux (All task_struct), but the way that data can be shared between processes is implemented only through very complex IPC, where the code is shared and the address space is shared, so the way to share data is more efficient. (Process to consider isolation, one process has no way to directly access another process; threads do not have to be quarantined, shared memory between threads)We modify a multithreaded vers
Java Concurrency structureOriginal link: http://gee.cs.oswego.edu/dl/cpj/mechanics.htmlContent
Thread
Synchronous
Monitor
ThreadA thread is a sequence of calls that are executed independently, and the threads of the same process share some system resources (such as file handles) at the same time to access the object resources (memory resources) created by the same process. The Java.lan
); } } }Static class withdrawthread implements Runnable {Account Account;intAmount PublicWithdrawthread (Account account,intAmount) { This. account = account; This. Amount = Amount; } Public voidRun () { for(inti =0; I 100000; i++) {Account.withdraw (amount); } } } }The first execution result is 10200, the second execution result is 1060, and the result of each execution is indeterminate, because the order in which the thre
Java concurrency,
I declare in advance that I am only a newbie to java concurrency. This article is just a summary and insights I have read the art of java concurrent programming (the content mainly involves the first three chapters. I hope you can discuss more about the er
Today's review is familiar with some concepts of Java concurrency.Program: The system to complete a task, is a program;Process: Each running program is a process, Windows Task Manager can see each process, Linux under the use of the ps–e command to view all currently running processes;Threads: Each running program (process) may contain multiple sequential execution flows, each of which can be considered a thread.1. Characteristics of the process:1) In
[Why use concurrency ?]1. ImproveProgramRunning SpeedWhen running on a multi-core or multi-processor system, concurrent programs can take full advantage of multiple execution units to speed up; however, when running concurrent programs on a single processor, there are two scenarios: when there is a blocking in the Program (for example, I/O blocking), concurrency can increase the speed. If it is a CPU-consum
only need to write some packages that can achieve our goal, we will adjust it based on our specific needs ". However, it is often because you have quickly extended the compiled simple tool and tried to add more features until you compile a complete infrastructure service. At this point, you usually stick to the program you write, whether it is good or bad. You have already paid all the cost for building your own program, so in addition to the actual migration cost invested by the general implem
IntroductionWhen it comes to the volatile keyword, most developers have a certain understanding, which can be said to be a very familiar and very unfamiliar keyword for developers. The equivalent of lightweight synchronized, also known as lightweight locks, is less expensive than synchronized, with visibility, ordering, and partial atomicity, which is a very important keyword in Java concurrency. In this ar
" phenomenon and "the main memory synchronization delay in working memory" phenomenon.The Java language provides the volatile and synchronized two keywords to ensure the ordering of operations between threads, and the volatile keyword itself contains the semantics of prohibiting command reordering, while synchronized is the " A variable that allows only one thread to lock on it at the same time "this rule determines that two synchronized blocks holdin
Java concurrency concepts, base interfaces, and thread
This series of articles mainly on Java concurrency related content, including synchronization, lock, semaphore, blocking queue, thread pool, etc., the overall mind map is as follows:
This paper mainly explains the concurrency
a software program can have multiple threads can operate in parallel, as in Warcraft, a migrant workers mining, a peasant worker logging, a migrant worker out hunting, this is 3 threads.In fact, multithreading is more complex than multitasking, there are multiple threads will involve concurrency, concurrency that is, read and write to the memory will appear similar to the dirty read Phantom read (common DB
Transferred from: http://www.importnew.com/11345.htmlI just like the fresh stuff, and Java 8 has a lot of new things. This time I want to discuss one of my favorites: the Concurrency adder. This is a new collection of classes that they use to manage the counters that are read and written by multithreading . This new API, while significantly improving performance , still retains its simple and straightforwar
Java Concurrency programming: synchronizing containersTo facilitate the writing of thread-safe programs, Java provides threading and concurrency tools such as synchronization containers, concurrent containers, blocking queues, synchronizer (such as Countdownlatch). Today we are going to discuss the synchronization cont
, resulting in multi-tasking is the illusion of parallel operationIn fact, if there is only one CPU in the system, and the use of multi-threaded tasks, then these tasks in the real environment can not be real parallel. After all, a CPU can only run one instruction at a time, in which case multithreading is concurrent, not parallel; Real parallelism can only occur in multi-CPU systems Critical section A critical section is used to represent public resources, or shared data, that can be used
in the past single-core CPU era, single-tasking can only execute a single program at a time point, with the development of multicore CPUs, parallel program development is particularly important. "Practical Java High concurrency Program design" mainly introduces the basis of Java-based parallel programming, ideas, methods and actual combat. First, based on the Con
daemon thread is an infinite loop to wait for a service request or to perform a thread's task. They cannot do important work because it is impossible to know when the daemon will be able to get the CPU time slice, and when no other thread is running, the daemon thread may end at any time. A typical daemon thread is the Java garbage collector (garbage Collector).Vii. Grouping of threadsJava provides a Threadgroup class that represents a set of threads
, or a timeout parameter can be taken in the join method. Calls to the join () method can be interrupted and calls to the interrupt () method on the calling thread .Two shared restricted resources1. Sharing resources 2. Changes are involved 3. Multiple threads usingBasically, all concurrency patterns are used to serialize access to shared resources when resolving thread-conflict problems-that is, only one thread is allowed to access the shared resourc
this process, thread B gets to the value of n is an old value, although equal to the current value of N, but actually the value of n has undergone a change of 1 to 2 to 1The above example is a typical ABA problem.How to solve the ABA problemAdd a version number to the variable, and compare the value of the current variable to compare the version number of the current variable. Atomicstampedreference in Java solves this problem.
Long cycle times c
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.