java - what is the difference between public static synchronized and public static? -


as said , difference between public static synchronized .. , public static ? example ?

one point have careful (several programmers fall in trap) there no link between synchronized static methods , non synchronized static methods, ie:

class {     public static synchronized f() {...} //class level lock     public static g() {...} //object level lock } public class testa{     public static void main(string[] args){         a = new a();        //thread 1:        a.f();        //thread 2:        a.g();     } } 

f() , g() not synchronized each other , can execute totally concurrently.


Comments

Popular posts from this blog

Javascript line number mapping -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -