`
文章列表
package com.bjsxt.height.concurrent018; import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.BlockingQueue; import java.util.concurrent.ExecutorService; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadPoolExecutor; import java.util.co ...
package com.bjsxt.height.concurrent017; import java.util.concurrent.Executors; import java.util.concurrent.ExecutorService; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; class Temp extends Thread { ...
多线程架构 1 Executor 方法: 1 Executors.newFixedThreadPool(int); 该方法返回固定线程数,线程数始终不变,当有一个任务 提交时,若线程池中空闲,则立即执行,若没有, 则会被暂缓在一个任务队列中等待有空闲执行提交。 源码: ThreadPoolExecutor(nThreads(核心线程也就是初始化几个线程) , nThreads(最大线程数), 0L, TimeUnit.MILLISECONDS(每个线程执行完任务之后停留能活多久), new LinkedBlockingQueue<Runnable>()( ...
package com.bjsxt.height.design016; import java.util.concurrent.BlockingQueue; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.LinkedBlockingQueue; public class Main { public static void main(String[] args) throws Exception ...
package test; import java.util.Random; public class Main { public static void main(String[] args) { System.out.println("我的机器可用Processor数量:" + Runtime.getRuntime().availableProcessors()); Master master = new Master(new MyWorker(), Runtime.getRuntime().availableProcessors()); ...
package com.bjsxt.base.coll013; public class Task implements Comparable<Task>{ private int id ; private String name; public int getId() { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; } public vo ...
package com.bjsxt.base.coll013; import java.util.Iterator; import java.util.concurrent.DelayQueue; /** * @author Administrator *DelayQueue: 带有延迟时间的Queue,其中元素只有当指定时间到了,才能从队列中取该元素。 DelayQueue中的对象必须实现Delayed接口,没有限制大小,应用场景很多, 比如,对缓存超时的数据进行移除,任务超时处理、空闲连接关闭等等。 */ public class WangBa impl ...
package com.bjsxt.base.coll013; import java.util.concurrent.SynchronousQueue; /** ConcurrentLinkedQueue : 先进先出高并发队列。无锁、无阻塞。不允许null元素。 先进在头,后进在尾。 方法 :add( )、 offer() 、Poll()从头部取出元素,并 ...
copyandwrite 容器 CopyOnWriteArrayList CopyOnWriteArraySet CopyOnWriteArrayList和CopyOnWriteArraySet分别代替List和Set, 主要是在遍历操作为主的情况下来代替同步的List和同步的Set,这也就是上面所述的思路:迭代过程要保证不出错,除了加锁,另外一种方法就是"克隆"容器对象。 :适合读多写少的情况。读写分离的容器   8 ConcurrentHashMap 并发容器 引入了java.util.concurrent包。与Vector和Hashtable、 C ...
package com.bjsxt.base.coll012; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Vector; /** * 多线程使用Vector或者HashTable的示例(简单线程同步问题) * @author alienware * 二、线程安 ...
package com.bjsxt.base.conn011; /** * 多线程单列 第一种写法,最简单。 * @author Administrator * */ public class InnerSingleton { private static class Singletion { private static Singletion single = new Singletion(); } public static Singletion getInstance(){ return Singletion.single; ...
package com.bjsxt.base.queue; import java.util.LinkedList; import java.util.concurrent.atomic.AtomicInteger; public class Myqueue { private final LinkedList<Object> list = new LinkedList<Object>(); private AtomicInteger count = new AtomicInteger(); private final i ...
package com.bjsxt.base.sync007; import java.util.concurrent.atomic.AtomicInteger; /** * volatile关键字不具备synchronized关键字的原子性(同步) * 可以使用AtomicInteger 替代普通变量或者用 synchronized修饰方法 * @author alienware * */ public class Vol ...
hive> select count(url) from track_log;Total MapReduce jobs = 1Launching Job 1 out of 1Number of reduce tasks determined at compile time: 1In order to change the average load for a reducer (in bytes):  set hive.exec.reducers.bytes.per.reducer=<number>In order to limit the maximum number of ...

Multimap

    博客分类:
  • java
本文转至:http://www.cnblogs.com/xiaoka/archive/2011/08/15/2139805.html                        
Global site tag (gtag.js) - Google Analytics