多线程:http://www.cnblogs.com/wxd0108/p/5479442.html
1,状态:
sleep()
yield()
join()
interrupte()
wait()/notify() 必须放入synchronized{}中
2, volatile: 变量一次获取从“主存”到“线程栈”,执行load and save, 即不使用缓存。
3, ExecutorService es = new Executor.newFixedThreadPool(3); newCachedThreadPool(); newSingleThreadPool();
Future fu = es.submit( new MyCallable());
fu.isDone();
fu.get()
4, ThreadLocal:
为变量对应的线程提供一个副本。
ThreadLocalMap: 内部类
以自己本身为key,以变量为value.
5, 原子类: AtomicInteger....,相当于给变量加上了synchronized
6, Lock
ReentranceLock
ReentranceReadWriteLock.readLock
ReentranceReadWriteLocak.writeLock
7, BlockingQueue
ConcurrentHashMap
1,状态:
sleep()
yield()
join()
interrupte()
wait()/notify() 必须放入synchronized{}中
2, volatile: 变量一次获取从“主存”到“线程栈”,执行load and save, 即不使用缓存。
3, ExecutorService es = new Executor.newFixedThreadPool(3); newCachedThreadPool(); newSingleThreadPool();
Future fu = es.submit( new MyCallable());
fu.isDone();
fu.get()
4, ThreadLocal:
为变量对应的线程提供一个副本。
ThreadLocalMap: 内部类
以自己本身为key,以变量为value.
5, 原子类: AtomicInteger....,相当于给变量加上了synchronized
6, Lock
ReentranceLock
ReentranceReadWriteLock.readLock
ReentranceReadWriteLocak.writeLock
7, BlockingQueue
ConcurrentHashMap