第一种 synchronized(对象){需要被同步的代码 };第二中:用作修饰函数为同步函数public synchronized void 函数名(){ } 转载于:https://www.cnblogs.com/liyunchuan/p/10713196.html