众所周知,AtomicInteger用于多线程下线程安全的数据读写操作,避免使用锁同步,底层采用CAS实现,内部的存储值使用volatile修饰,因此多线程之间是修改可见的。 1. 构造 public AutomicInteger(int initValue): 有参构造,初始化为initValue public AutomicInteger(): 无参构造,相当于AutomicInteger(0) 2. 自增1 public int getAndIncrement(): 返回当前值,并自增1 public int incrementAndGet(): 先自增1,再返回自增后的值 3. 自减1 public int getAndDecrement(): 返回当前值,并自减1 public int decrementAndGet(): 自减1, 返回自减后的值 4.
Is this you? As a journalist, you can create a free Muck Rack account to customize your profile, list your contact preferences, and upload a portfolio of your best work.
Claim your profile