java concurrent
curiousby
这个作者很懒,什么都没留下…
展开
-
Callable 与 Future
ava.util.concurrent.Executors;import java.util.concurrent.Future;public class CallableTest { // 异步 木桶原理 public static void main(String[] args) throws InterruptedException, ExecutionException { ExecutorService executorService = Executors.ne原创 2018-01-25 17:51:59 · 78 阅读 · 0 评论 -
CountDownLatch
A,它要等待其他4个任务执行完毕之后才能执行,此时就可以利用CountDownLatch来实现这种功能 public static void main(String[] args) throws InterruptedException { ExecutorService newFixedThreadPool = Executors.newFixedThreadPool(10); int num = 10; CountDownLatch cdl = new CountDownLatc原创 2018-01-25 17:53:15 · 96 阅读 · 0 评论 -
CyclicBarrier
c void main(String[] args) throws InterruptedException { ExecutorService newFixedThreadPool = Executors.newFixedThreadPool(10); int num = 5 ; CyclicBarrier cyclicBarrier = new CyclicBarrier(num); for (int i = 0; i < 5; i++) { newFix原创 2018-01-25 17:43:12 · 79 阅读 · 0 评论 -
ExecutorService
util.concurrent.ScheduledExecutorService;import java.util.concurrent.ThreadPoolExecutor;import java.util.concurrent.TimeUnit;public class ExecutorServiceTest { public static void main(String[] args) { ExecutorService exe =null; exe = E原创 2018-01-25 17:55:21 · 75 阅读 · 0 评论 -
Semaphore
原创 2018-01-25 17:46:22 · 121 阅读 · 0 评论 -
Collections,Synchronized
atic List synchronizedList(list l)////public static Map synchronizedMap(Map m)////public static Set synchronizedSet(Set s)////public static SortedMap synchronizedSortedMap(SortedMap sm)////public static SortedSet synchronizedSortedSet(Sorte原创 2018-01-26 09:53:51 · 83 阅读 · 0 评论 -
join
原创 2018-01-26 09:42:32 · 89 阅读 · 0 评论 -
ReentrantLock,Condition
i++) { queue.put("a"); String string = queue.getString(); System.out.println(string); } } public abstract class MessageQueue<T>{ private Queue<T> queue; private List<原创 2018-01-26 09:42:11 · 88 阅读 · 0 评论