As a result of the recent preparation of some written review of the relevant Java knowledge points, can't help feeling: So many years to Java know too little!
1. About the Finally keyword
One of the ibmdeveloperworks has been explained in great detail:
On the depth discrimination of finally statement block in Java
Add to the original idea of designing a finally statement for the Java designer: We can't know when the exception happened, but we need to make sure that it does not matter if it has some critical resources that are handled properly (such as IO streams, database connections, and so on) when the GC reclaims memory.
Error point: The execution mechanism of the finally statement before return
2. Keyword synchronized,volatile,transient
The ①synchronized keyword is a sync keyword that includes two usages: the Synchronized method and the synchronized block of code.
②volatile-Modified member variables force the value of the member variable to be read from shared memory each time it is accessed by a thread. Also, when a member variable changes, the forcing thread writes the value of the change back to shared memory. So at any moment, two different threads always see the same value for a member variable, which can only be used to modify a variable.
The ③transient keyword indicates that the property is not saved when the object is serialized (serialization, persisted). It can only be used to modify variables or constants.
Easy-to-ignore Java knowledge points (collation ing)