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
Post a Comment