基本类型想要引用传递需要用原子类,
String: 用 StringBuffer(线程安全的)
使用:
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("a");
stringBuffer.append("b");
整形:AtomicInteger
使用
AtomicInteger is_show_switch = new AtomicInteger(0);
// 设置
is_show_switch.set(1);
// 获取
is_show_switch.get();
布尔值:AtomicBoolean
使用
AtomicBoolean is_show_switch = new AtomicBoolean(false);
// 设置
is_show_switch.set(true);
// 获取
is_show_switch.get();