- 博客(12)
- 收藏
- 关注
转载 ReentrantLock 锁与唤醒锁
public class UseManyCondition { private ReentrantLock lock = new ReentrantLock(); private Condition c1 = lock.newCondition(); private Condition c2 = lock.newCondition(); pu
2017-03-30 18:27:19
382
转载 Semaphore控制访问量
public class UseSemaphore { public static void main(String[] args) { // 线程池 ExecutorService exec = Executors.newCachedThreadPool(); // 只能5个线程同时访问
2017-03-30 18:06:51
311
转载 CountDownLatch与CyclicBarrier
public class UseCountDownLatch { public static void main(String[] args) { final CountDownLatch countDown = new CountDownLatch(2); Thread t1 = new Thread(ne
2017-03-30 17:34:39
261
转载 自定义线程池
有些时候 jdk自带的cachedThreadPool fixedThreadPool等线程池完成不了我们业务的需求时 可以用ThreadPoolExecutorg构造自定义的线程池。public class UseThreadPoolExecutor1 { public static void main(String[] args) { /**
2017-03-30 16:42:55
334
转载 多线程_消费者生产者模型
import java.util.Random;import java.util.concurrent.BlockingQueue;import java.util.concurrent.TimeUnit;import java.util.concurrent.atomic.AtomicInteger;public class Provider implements Runna
2017-03-30 16:17:56
272
转载 DelayQueue
public class WangBa implements Runnable { private DelayQueue queue = new DelayQueue(); public boolean yinye =true; public void shangji(String name,String id,in
2017-03-28 13:29:35
243
转载 ConcurrentLinkedQueue ArrayBlockingQueue SynchronousQueue例子
final SynchronousQueue q = new SynchronousQueue(); Thread t1 = new Thread(new Runnable() { @Override public void run() { try {
2017-03-28 12:10:21
397
转载 优先级阻塞队列
public class Task implements Comparable{ private int id ; private String name; public int getId() { return id; } public void setId(int id) { this.id =
2017-03-28 11:52:45
349
转载 单例-内部类
package com.bjsxt.base.conn011;public class Singletion { private static class InnerSingletion { private static Singletion single = new Singletion(); } public st
2017-03-28 10:45:40
276
转载 多线程-阻塞队列
public class MyQueue { //1 需要一个承装元素的集合 private LinkedList list = new LinkedList(); //2 需要一个计数器 private AtomicInteger count = new AtomicInteger(0); //3 需要制定上
2017-03-28 10:37:03
288
翻译 多线程学习笔记1
public class MutiSyn { public synchronized void method01(){ System.out.println("1"); method02(); } public synchronized void method02(){ System.out.println("2"
2017-03-28 10:03:14
232
原创 关于java的内存泄露
先说一下内存泄露,内存泄露不会表现出明显的失败,可以在一个系统存在很多年,Heap的解析工具Heap Profiler可以发现内存泄露问题。这是一个内存泄露的经典例子,这个栈管理自己的内存,必须注意内存泄露问题,一旦元素被释放,该元素的任何对象引用都应该被清空package com.shi;import java.util.Arrays;import java.util
2016-11-27 17:16:42
249
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人