`
文章列表
//一个可以异步返回计算的结果 //它同时实现了Future和Runnable //先看构造函数 public FutureTask(Callable<V> callable) { if (callable == null) throw new NullPointerException(); this.callable = callable; this.state = NEW; // ensure visibility of callable } //运行runna ...
//数据结构是跳表 关于数据结构http://blog.csdn.net/coslay/article/details/44819823这篇文章写得很好 //另外ConcurrentSkipListSet底层也是用ConcurrentSkipListMap实现的。 //先看构造函数 public ConcurrentSkipListMap() { this.comparator = null; initialize(); } public ConcurrentSkipListMap(Comparator<? super K> ...

读TreeMap源码

//一个基于二叉红黑树实现的map //关于红黑树http://blog.csdn.net/chenssy/article/details/26668941这篇博客写的非常好 //另外TreeSet的是用TreeMap实现的。(组合设计模式,将所有的实现委托给TreeMap实现) //先看构造函数 public TreeMap() { comparator = null; } public TreeMap(Comparator<? super K> comparator) { this.comparator = c ...
//一个信号量,只有在池中还拥有许可时才允许线程继续执行。 //先看构造函数 //默认是非公平模式 public Semaphore(int permits) { sync = new NonfairSync(permits); } NonfairSync(int permits) { super(permits); } //设置状态 Sync(int permits) { setState(permits); } public Semaphore ...
oracle中分组查询并且查询每组前几条数据 select * from ( SELECT b,c,row_number() OVER(PARTITION BY b ORDER BY c desc) e FROM test_table) t where e <= 3 b为分组字段, c为排序字段
//一个循环的屏障。所有的线程在屏障处等待其他线程执行完毕。然后再各自执行。 //先看构造函数 public CyclicBarrier(int parties) { this(parties, null); } //barrierAction代表在屏障上等待的最后一个线程已经执行完后,执行的runnable public CyclicBarrier(int parties, Runnable barrierAction) { if (parties <= 0) throw new IllegalArgumentExcep ...
//在完成一组操作之前允许一个或多个线程等待内部用的AQS private static final class Sync extends AbstractQueuedSynchronizer { private static final long serialVersionUID = 4982264981922014374L; Sync(int count) { setState(count); } int getCount() { return get ...
//这是一个无阻塞的队列没有加任何锁全部利用CAS机制实现。效率极高。 //先看构造函数 public ConcurrentLinkedQueue() { head = tail = new Node<E>(null); } public ConcurrentLinkedQueue(Collection<? extends E> c) { Node<E> h = null, t = null; for (E e : c) { //元素不可以为null ...
//先看构造函数 public ConcurrentHashMap() { this(DEFAULT_INITIAL_CAPACITY, DEFAULT_LOAD_FACTOR, DEFAULT_CONCURRENCY_LEVEL); } public ConcurrentHashMap(int initialCapacity) { this(initialCapacity, DEFAULT_LOAD_FACTOR, DEFAULT_CONCURRENCY_LEVEL); } public ConcurrentHashMa ...

读HashSet源码

//先看构造函数 public HashSet() { map = new HashMap<>(); } public HashSet(int initialCapacity) { map = new HashMap<>(initialCapacity); } public HashSet(int initialCapacity, float loadFactor) { map = new HashMap<>(initialCapacity, loadFactor); ...
//写一个filter对response进行过滤 public class CrossFilter implements Filter{ @Override public void destroy() { // TODO Auto-generated method stub } @Override public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { ...
//List的链表实现,先看构造函数 public LinkedList() { } public LinkedList(Collection<? extends E> c) { this(); addAll(c); } public boolean addAll(Collection<? extends E> c) { return addAll(size, c); } public boolean addAll(int index, Collection& ...
//LinkedHashMap继承了HashMap,他和HashMap相比维持了一个插入时候的顺序。LinkedHashMap和HashMap之间也是一种模板设计模式的体现 //先看构造函数 public LinkedHashMap() { super(); //排序规则false按照插入顺序读出,true最近最少使用可用于做LRU(Least Recently Used)缓存 accessOrder = false; } public LinkedHashMap(int initialCapacity) { su ...
//先看构造函数 public ArrayList() { super(); this.elementData = EMPTY_ELEMENTDATA; } public ArrayList(int initialCapacity) { super(); if (initialCapacity < 0) throw new IllegalArgumentException("Illegal Capacity: "+ ...
public class SpringContextUtil implements ApplicationContextAware{ private static ApplicationContext applicationContext; @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { SpringContextUtil.applicationContext = applicationContext ...
Global site tag (gtag.js) - Google Analytics