This is a creation in
Article, where the information may have evolved or changed.
Brief introduction
When I first used Go channels work, I made a mistake to consider channels as a data structure. I see the channels as a queue that provides automatic synchronization access between Goroutines. This structural understanding leads me to write a lot of bad and complex concurrency code.
Over time, I realized that the best way is to forget that channels is a data structure and instead focus on its beha
program executes is executed in the order of the Code. For a simple example, look at the following code:
int i = 0;
Boolean flag = false;
i = 1; Statement 1
flag = true; Statement 2
The code above defines an int type variable, defines a Boolean type variable, and then assigns the two variables separately. In code order, statement 1 is in front of statement 2, so the JVM will guarantee that statement 1 will be
. Why? In fact, when we make this kind of choice, it will inevitably mean that the interface semantics changes. without changing the interface, it is actually impossible to choose (give it a try, use the return value to handle errors in the constructor ). The normal and abnormal conditions can be distinguished without changing the pattern, and the interface can be further refined.
The evaluation of exceptional security can be divided into three levels: basic assurance, strong assurance, and no
interface, it is actually impossible to choose (give it a try, use the return value to handle errors in the constructor ). The normal and abnormal conditions can be distinguished without changing the pattern, and the interface can be further refined.The evaluation of exceptional security can be divided into three levels: basic assurance, strong assurance, and no failure.Basic Guarantee: Make sure that the Program (object) is in an unknown but valid S
statement 1 must be executed before statement 2? Not necessarily, why? Command reordering (instruction Reorder) may occur here.The following explains what is Order reordering, in general, the processor may optimize the input code in order to improve the efficiency of the program, and it does not guarantee that the execution order of the individual statements in the program is consistent with the order in the code, but it will ensure that the results
In order to export the words accumulated in youdao dictionary and then import them to another English learning software named 91, the format exported from youdao dictionary is different from that required by 91 English language software, you must adjust the settings before importing data. For this reason, I spent half a day studying the word replacement function, especially the use of wildcard characters. For example:
Youdao export format:
1, statement ['steitm found nt]N. Declaration; statemen
, defines a Boolean variable, and assigns two variables to each. In code order, statement 1 is in front of statement 2, then the JVM will actually execute this code to ensure that statement 1 must be executed before statement 2. Not necessarily, for what. Command reordering (instruction Reorder) may occur here.
The following explains what is Order reordering, in general, the processor may optimize the input code in order to improve the efficiency of the program, and it does not
This is a creation in
Article, where the information may have evolved or changed.
2017-03-28 First Financial guarantee: Alliance chain success Verification will continue to explore blockchain support for high-frequency commercial transactions
March 28, the Shanghai Insurance Company jointly 9 insurance institutions successfully through the blockchain data trading technology verification . From function, performance, safety, operation and mai
that use non-volatile, the Java Virtual Machine (JVM) will not guarantee when the data is read from the main memory to the CPU cache, nor does it guarantee when the CPU cache data is written back to main memory. This will cause some problems. I'll explain it in detail later.Imagine that two or more than two threads can access a shared object that contains a single counter:Imagine that only thread 1 increas
recycled. If you have not escaped at this time, it is really going to be recycled.
Note: The Finalize () method is expensive, uncertain, and does not guarantee the order in which individual objects are called. Bloggers recommend that you completely forget the existence of this method in the Java language. How to recycle markup Cleanup Algorithm
The algorithm is divided into two phases: Mark and clear all the objects that need to be recycled, collect
). Basic Type: After an exception is thrown, all the constraints of the class are met, and the objects in the program are in a valid state.
(2). Strongly guaranteed type: After an exception is thrown, the program State does not change, and the function returns to the status before calling.
(3). Do not throw the exception type: ensure that no exception is thrown, all operations on the built-in type (int, pointer, etc.)
Both provide the nothrow guarantee
, delete the pointer service.
Rule 7.5 external interfaces of independent compiling modules or subsystems are prohibited from throwing exceptions
Note: There is no universal binary standard for exception handling, so cross-module Exception throwing is not allowed.
7.2 error handling policy
Principle 7.2 establish a reasonable error handling policy
Note: The errors mentioned here refer to runtime errors, rather than internal programming and design errors. Module Internal programming and design er
Today, I read an article on the Internet, talking about the volatile feature to use 1000 threads constantly accumulating numbers, each time the cumulative 1, to the final value is not 1000.The article is a bit misunderstood by others, but in the comments of the article, the author also points out the mistake.I based on the error of the article and the comments of netizens, summed up some of their own methods and ideas. I hope to discuss with you.Article Source: http://www.cnblogs.com/aigongsi/ar
(or synchronous code blocks). With locks, you can guarantee that only one thread can get the lock at the same time, and that only one thread can execute the code between the request lock and the release lock at the same time.
123456789
public void Testlock () {lock.lock (); try{Int j = i; i = j + 1;} finally {lock.unlock ();}}
Similar to locks are synchronous methods or synchronized code blocks. When you use a non-stat
it.Ordinary shared variables do not guarantee visibility, because when the normal shared variable is modified and when it is written to main memory is indeterminate, when other threads go to read, the memory may still be the original old value, so the visibility can not be guaranteed.
Order of
In the Java memory model, the compiler and the processor are allowed to reorder the instructions, but the reordering process does not affect the execution of
all data in the write buffer to memory.
Note knowledge:
There are 3 types of locks on CPUs:
3.1 Processor automatically guarantees the atomicity of basic memory operations
First, the processor automatically guarantees the atomic nature of the basic memory operation. The processor guarantees that reading or writing a byte from the system memory is atomic, meaning that when a processor reads a byte, the other processor cannot access the byte's memory address. Pentium 6 and the latest processors c
enables the completion of one instruction in a CPU clock cycle, thus increasing the CPU's computational speed. Memory sequence conflicts Memory order violation memory sequence conflicts are generally caused by false sharing, which means that multiple CPUs simultaneously modify the different parts of the same cache line and cause one of the CPU operations to be invalid, and when this memory sequence conflict occurs, the CPU must empty the assembly line.
3. How the processor implements atomic ope
transaction may run. You can allocate an approximate time to undo_retention Based on the longest transaction length in the database. You can use the maxquerylen column in the V $ undostat view to query the longest query execution time in seconds in the past ). The time setting in the undo_retention parameter should be at least as long as the time given in the maxquerylen column. Oracle provides the following guidance for setting a time interval for revoking a new database: 1. OLTP system: 15 mi
. It is common to simply use the volatile keyword to solve the compiler's problem of confusion, but these instructions can still be scrambled to the processor when it is executed. A set of memory barrier functions (barrier) is required for the avoidance of processor order execution.
ortant" border="0">
Important
The vast majority of compilers typically do not optimize access to volatile objects, and generally maintain a sequence of read and write operat
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.