JAVA静态方法的同步问题~~~~~~~~~~~~~

一直被同步搞得晕头转向,今天遇到了要写静态方法,总担心会不会有同步问题,结果看了以下一席话,豁然开朗~~

Every method of java will have a stack, and every invokation on thatmethod will have it’s own ‘stack frame’. So the locale data of onemethod invokation will not affect others.Please do not confuse ‘synchronization’ with ‘atomic’. If one static method is synchronized, JVM will use the Class as the lock. If not, it acts as an instance method.

意思是说,JAVA的每个方法每次调用都有一个栈,所以方法里面的变量不会相互影响~~~

世界没有永久的冬天;不要讨厌麻烦,

JAVA静态方法的同步问题~~~~~~~~~~~~~

相关文章:

你感兴趣的文章:

标签云: