Java in the final static volatile keyword []

final

Modified class: the class inheritance is prohibited. Why use the final String modification? Immutability String can not be modified. Avoid modify the inheritance semantics.

Modifying variables: that they can not change the reference. That has been quoted C A, C can not be referenced B.

 

static:

Modifying variables: Static variables are shared by all the objects, only one copy in memory, if and only if it will be initialized when the class first loads. Initialization sequence static member variables are initialized defined sequence.

     Lifecycle static variables are the same lifecycle and class (class unload when the static variable will be destroyed).

  Lifecycle class: Under normal circumstances, the default system class loader during program run, it will not take the initiative to uninstall class, that is the same type of life-cycle process and life cycle operation, under special circumstances, use a custom the class loader, you can uninstall an active class, the class of the life cycle will be terminated;

   After completion of the use of the class, if the following conditions is true class is unloaded:

  • All instances of the class have been recovered, that is java heap any instance of the class does not exist.
  • Load class ClassLoader has been recovered. (Class loader?)
  • Java.lang.Class corresponding to the class object is not referenced anywhere, not reflected by the method of accessing the class anywhere.

Modification method: There is a class class, does not belong to any instance of an object.

static block of code: When first loaded class, each static block will be performed in the order of static blocks, and only once (many tasks may only need to perform initialization time).

 

volatile :( and about the Java Memory Model)

 

Guess you like

Origin www.cnblogs.com/lovelywxd/p/9171948.html