Java: understanding the execution of static methods
•
Java
There are printa in class A and printb in class B. There are two methods Printa is a static method and printb is a non - static method Both methods are synchronous 100 million threads were launched on printa and printb respectively@ H_ 403_ 7@
Solution
If you have many objects and multiple processor cores, you may find printb faster Printa synchronizes on class objects, so all calls to it are done one at a time Printb is synchronized on its object, so multiple printb calls can run in parallel@ H_ 403_ 7@
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码