Java achieved the support to line Cheng on language administrative levels. It offerred Thread/Runnable/ThreadGroup to wait for a series of enclosing kind with interface, the Cheng of development Java multi-line that makes programmer OK and efficient applies. To realize synchronism, java provided the Wait()/notify() mechanism of Synchronize key word and Object, can be the backside that using easily simply, should hide more complex mystery, a lot of problems are from this and case.
One, Java memory model
Before the synchronism that understands Java is secret, will see JMM(Java Memory Model) first.
Java is to cross the language of platform by the design, on memory management, also want to have an unified model apparently. And the characteristic with Java the biggest language abolished namely pressing with a finger, come out programmer from the disengagement in anguish, need not consider to memory is used and manage the problem of the respect again.
Regrettablly affairs of human life always is like person meaning very much, although programmer went to the lavatory on JMM design, but the complex rate that it raised fictitious chance, and still bring about skill of certain process designing to be in Java language invalidation.
JMM basically is to set a few concerns between line Cheng and memory. Need to be in charge of using Synchronized synchronous key word only to Java programmer, other such as and line Cheng / undertake data is exchanged between memory / the trival job such as synchronism all is in charge of finishing by fictitious machine. If the graph shows 1 times: According to the design of JMM, the system exists advocate memory (Main Memory) , all variable in Java store in advocate in putting, wired to place Cheng is shared. The working memory that every line Cheng has him (Working Memory) , what save in working memory is advocate the copy of certain variable in putting, line Cheng is to all variable operations undertake in working memory, cannot visit directly each other between line Cheng, variable is delivered all need to pass advocate put finish.

Give typical examples of model of memory of graph 1 Java pursues
If line Cheng wants to undertake operating to some variable, must pass a series of measure: Above all from advocate put duplicate / refresh data arrives working memory, implement code next, undertake quotative / assignment operation, keep variable content finally a Main Memory. Java language standard (mix to line Cheng in JLS) advocate the operation that keep each other defined 6 conduct, it is Load respectively, save, read, write, assign and Use, these operation behavior have atomic sex, and interdependent, have call clearly early or late ordinal. Specific description refers to JLS please the 17th chapter.
Previous12 3 4 5 6 7 8 Next