- 博客(7)
- 资源 (2)
- 收藏
- 关注
转载 LinkedBlockingQueue vs ConcurrentLinkedQueue
LinkedBlockingQueue is intended for use cases when consumers and producersconcurrently consume and produce. In this case, for example the consumers might get ahead of producers and empty the queue
2014-05-30 14:10:04 599
转载 Does Java pass by reference or pass by value?
Q: If Java uses the pass-by reference, why won't a swap function work? A: Java does manipulate objects by reference, and all object variables are references. However, Java doesn't pass method argumen
2014-05-23 18:17:42 612
原创 How to create different types of thread pool in Java
It is easier to create thread pool by using java.util.concurrent.Executors. /** * Creates a thread pool that reuses a fixed number of threads * operating off a shared unbounded queue.
2014-05-08 16:56:58 760
原创 A better way to shutdown the thread pool in Java
The following method shuts down an ExecutorService in two phases, first by calling shutdown to reject incoming tasks, and then calling shutdownNow, if necessary, to cancel any lingering tasks: vo
2014-05-08 15:07:15 467
转载 When to use AtomicReference?
Atomic reference should be used in a setting where you need to do simple atomic (i.e., thread safe, non-trivial) operations on a reference, for which monitor-based synchronization is not appropriate.
2014-05-08 14:17:53 469
转载 What is a race condition?
A race condition occurs when two or more threads can access shared data and they try to change it at the same time. Because the thread scheduling algorithm can swap between threads at any time, you do
2014-05-08 10:57:58 723
转载 When and how should I use a ThreadLocal variable?
One possible (and common) use is when you have some object that is not thread-safe, but you want to avoid synchronizing access to that object (I'm looking at you,SimpleDateFormat). Instead, give eac
2014-05-07 15:33:24 459
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人