1、Java.util.concurrent.atomic包下的原子类 AtomicXXXX(Atomic意为原子的)
例如:AtomicInteger AtomicBoolean AtomicLong
AtomicIntegerArray、AtomicLongArray:该类是Java对Integer数组和Long数组反对的原子性操作;
2、常见的汇合类
List:Vector (效率低,不倡议用)
Map:ConcurrentHashMap HashTable ConcurrentSkipListMap
Set:ConcurrentSkipListSet
ConcurrentSkipListSet和TreeSet,它们尽管都是有序的汇合。然而,第一,它们的线程平安机制不同,TreeSet是非线程平安的,而ConcurrentSkipListSet是线程平安的。第二,ConcurrentSkipListSet是通过ConcurrentSkipListMap实现的,而TreeSet是通过TreeMap实现的。
3、可变字符串:StringBuffer也是线程平安
4、BlockingQueue 和 BlockingDequeBlockingDeque
接口继承了BlockingQueue
接口, BlockingQueue
接口的实现类有ArrayBlockingQueue
,LinkedBlockingQueue
,PriorityBlockingQueue
而BlockingDeque
接口的实现类有LinkedBlockingDeque
BlockingQueue
和BlockingDeque
都是通过应用定义为final的ReentrantLock
作为类属性显式加锁实现同步的
发表回复