Synchronized methods can be static - a thread acquires the class monitor before executing the static
synchronized methods
! Synchronization of static methods in a class is independent from the synchronization of instance methods
on objects of the class

解决方案 »

  1.   

    我想你没理解"多线程"的概念
    普通单线程程序,现在我们用的是串行的程序执行,
    而synchronized关键字是用来在多线程执行的时候用来保持同步,和你说的情况,不是一回事,
    你的情况不管用不用synchronized关键字,在同一个时刻只能有一个代码段执行。
      

  2.   

    synchronized的作用就是保持多线程时的同步,也就是说一般只有在用到多线程时才会用到synchronized。
      

  3.   

    synchronized不一定只用在多线程的程序中吧,再说JAVA本身就是多线程的!