多线程访问synchronized方法,一旦某个进程抢得锁之后,其他的进程只有排队对待。
synchronized void method { dosometing(); }
功能上,等效于:
void method { synchronized(this) { dosometing(); } }