public static synchronized strictfp void main(String... arg)
In the above statement, can someone please explain the purpose of synchronized
and strictfp
for main
method.
public static synchronized strictfp void main(String... arg)
In the above statement, can someone please explain the purpose of synchronized
and strictfp
for main
method.
Few good explanation for java synchronized is given here - what-does-synchronized-mean and learning-java-use-of-synchronized-keyword
Now, if main method is synchronized, only one thread can enter into this method, which is the java main thread (assuming that the class is executed as main class).
For executing this method, the main thread will acquire the class level lock (being a static method). So, if the class is having more static synchronized methods, those will be blocked forever for other thread, until main thread completes the execution or go into wait state.
strictfp is Java is explained when-should-i-use-the-strictfp-keyword-in-java and strictfp-in-java
It does not have any different behavior with main()
.