package com.gxx.threads.study.test20; /** * 方法处理器 * @author Gxx */ public class MethodProcess { /** * 方法A */ public synchronized void methodA(){ System.out.println("[" + Thread.currentThread().getName() + "]进入methodA~"); try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println("[" + Thread.currentThread().getName() + "]methodA结束"); } /** * 方法B */ public synchronized void methodB(){ System.out.println("[" + Thread.currentThread().getName() + "]进入methodB~"); System.out.println("[" + Thread.currentThread().getName() + "]methodB结束"); } }