package com.gxx.threads.study.test15; /** * 数字处理器 * @author Gxx */ public class NumProcess { /** * 处理逻辑 */ public void process(){ System.out.println("[" + Thread.currentThread().getName() + "]进入process~"); /** * 方法内变量 */ int num; /** * 根据线程名称走不同分支 */ if(Thread.currentThread().getName().equals("线程A")){ num = 100; try { Thread.sleep(2000);//睡眠2秒 } catch (InterruptedException e) { e.printStackTrace(); } } else { num = 200; } System.out.println("[" + Thread.currentThread().getName() + "] num=" + num); } }