delayQueue) {
- this.delayQueue = delayQueue;
- }
-
- @Override
- public void run() {
- while (true){
- try {
- DelayElem element = delayQueue.take();
- System.out.println(System.currentTimeMillis() +" 获取元素:" + element);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- }
- }
-
-
- private static class DelayElem implements Delayed {
-
- /**
- * 延迟时间
- */
- private final long delay;
- /**
- * 到期时间
- */
- private final long expire;
- /**
- * 数据
- */
- private final String msg;
-
- private DelayElem(long delay, String msg) {
- this.delay = delay;
- this.msg = msg;
- //到期时间 = 当前时间+延迟时间
- this.expire = System.currentTimeMillis() + this.delay;
- }
-
- /**
- * 需要实现的接口,获得延迟时间
- *
- * 用过期时间-当前时间
- * @param unit 时间单位
- * @return 延迟时间
- */
- @Override
- public long getDelay(TimeUnit unit) {
- return unit.convert(this.expire - System.currentTimeMillis() , TimeUnit.MILLISECONDS);
- }
-
- /**
- * 用于延迟队列内部比较排序
- *
- * 当前时间的延迟时间 - 比较对象的延迟时间
- *
- * @param o 比较对象
- * @return 结果
- */
- @Override
- public int compareTo(Delayed o) {
- return (int) (this.getDelay(TimeUnit.MILLISECONDS) - o.getDelay(TimeUnit.MILLISECONDS));
- }
-
- @Override
- public String toString() {
- return "DelayElem{" +
- "delay=" + delay +
- ", expire=" + expire +
- ", msg='" + msg + '\'' +
- '}';
- }
-
- }
-
- public static void main(String[] args) throws InterruptedException {
- DelayQueue delayQueue = new DelayQueue<>();
-
- new WriteThread(delayQueue).start();
- new ReadThread(delayQueue).start();
- }
-
-}
diff --git a/lock-test/src/test/java/com/github/houbb/lock/test/lock/LinkedBlockingDequeDemo.java b/lock-test/src/test/java/com/github/houbb/lock/test/lock/LinkedBlockingDequeDemo.java
deleted file mode 100644
index d7c3845..0000000
--- a/lock-test/src/test/java/com/github/houbb/lock/test/lock/LinkedBlockingDequeDemo.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package com.github.houbb.lock.test.lock;
-
-import java.util.concurrent.BlockingDeque;
-import java.util.concurrent.LinkedBlockingDeque;
-import java.util.concurrent.ThreadLocalRandom;
-
-/**
- * @author binbin.hou
- * @since 1.0.0
- */
-public class LinkedBlockingDequeDemo {
-
- private static class Producer implements Runnable{
- private BlockingDeque queue;
- public Producer(BlockingDeque queue) {
- this.queue = queue;
- }
- @Override
- public void run() {
- while(true) {
- try {
- Integer num = ThreadLocalRandom.current().nextInt(100);
- queue.put(num);
- System.out.println(String.format("%s producer a num %d",Thread.currentThread().getName(),num));
- Thread.sleep(1000);
- } catch (InterruptedException e1) {
- e1.printStackTrace();
- }
- }
- }
- }
-
- private static class Consumer implements Runnable{
- private BlockingDeque queue;
- public Consumer(BlockingDeque queue) {
- this.queue = queue;
- }
- @Override
- public void run() {
- while(true) {
- try {
- System.out.println(String.format("%s consume a num %d",Thread.currentThread().getName(),queue.take()));
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- }
- }
-
- public static void main(String[] args) {
- BlockingDeque queue = new LinkedBlockingDeque<>(100);
- new Thread(new Producer(queue),"Producer").start();
- new Thread(new Consumer(queue),"Consumer").start();
- }
-
-
-}
diff --git a/lock-test/src/test/java/com/github/houbb/lock/test/lock/LinkedBlockingQueueDemo.java b/lock-test/src/test/java/com/github/houbb/lock/test/lock/LinkedBlockingQueueDemo.java
deleted file mode 100644
index 4a2420e..0000000
--- a/lock-test/src/test/java/com/github/houbb/lock/test/lock/LinkedBlockingQueueDemo.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package com.github.houbb.lock.test.lock;
-
-import java.util.concurrent.*;
-
-/**
- * @author binbin.hou
- * @since 1.0.0
- */
-public class LinkedBlockingQueueDemo {
-
- private BlockingQueue queue = new LinkedBlockingQueue<>(3);
-
- public void put(final String put) throws InterruptedException {
- System.out.println("设置开始");
- TimeUnit.SECONDS.sleep(1);
- queue.put(put);
- System.out.println("设置完成: " + put);
- }
-
- public void take() throws InterruptedException {
- System.out.println("获取开始");
- String take = queue.take();
- System.out.println("获取成功: " + take);
- }
-
- public static void main(String[] args) {
- final LinkedBlockingQueueDemo queueTest = new LinkedBlockingQueueDemo();
- // 写入线程
- new Thread(new Runnable() {
- @Override
- public void run() {
- try {
- for(int i = 0; i < 3; i++) {
- queueTest.put(i+"T");
- }
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- }).start();
-
- // 读取线程
- new Thread(new Runnable() {
- @Override
- public void run() {
- try {
- while (true) {
- queueTest.take();
- }
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- }).start();
- }
-
-}
diff --git a/lock-test/src/test/java/com/github/houbb/lock/test/lock/PriorityBlockingQueueDemo.java b/lock-test/src/test/java/com/github/houbb/lock/test/lock/PriorityBlockingQueueDemo.java
deleted file mode 100644
index 873254a..0000000
--- a/lock-test/src/test/java/com/github/houbb/lock/test/lock/PriorityBlockingQueueDemo.java
+++ /dev/null
@@ -1,86 +0,0 @@
-package com.github.houbb.lock.test.lock;
-
-import java.util.concurrent.PriorityBlockingQueue;
-import java.util.concurrent.ThreadLocalRandom;
-import java.util.concurrent.TimeUnit;
-
-/**
- * @author binbin.hou
- * @since 1.0.0
- */
-public class PriorityBlockingQueueDemo {
-
- private static class User implements Comparable {
-
- private final int order;
-
- private final String name;
-
- private User(int order, String name) {
- this.order = order;
- this.name = name;
- }
-
- @Override
- public int compareTo(User o) {
- return this.order - o.order;
- }
-
- @Override
- public String toString() {
- return "User{" +
- "order=" + order +
- ", name='" + name + '\'' +
- '}';
- }
- }
-
- private PriorityBlockingQueue queue = new PriorityBlockingQueue<>();
-
- public void put(final User user) throws InterruptedException {
- System.out.println("设置开始");
- queue.put(user);
- System.out.println("设置完成: " + user);
- }
-
- public void take() throws InterruptedException {
- TimeUnit.SECONDS.sleep(1);
- System.out.println("获取开始");
- User take = queue.take();
- System.out.println("获取成功: " + take);
- }
-
- public static void main(String[] args) {
- final PriorityBlockingQueueDemo queueTest = new PriorityBlockingQueueDemo();
- // 写入线程
- new Thread(new Runnable() {
- @Override
- public void run() {
- try {
- for(int i = 0; i < 5; i++) {
- int order = ThreadLocalRandom.current().nextInt(10);
- User user = new User(order, i+"-user");
- queueTest.put(user);
- }
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- }).start();
-
- // 读取线程
- new Thread(new Runnable() {
- @Override
- public void run() {
- try {
- while (true) {
- queueTest.take();
- }
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- }).start();
- }
-
-}
diff --git a/lock-test/src/test/java/com/github/houbb/lock/test/lock/SynchronousQueueDemo.java b/lock-test/src/test/java/com/github/houbb/lock/test/lock/SynchronousQueueDemo.java
deleted file mode 100644
index 6223f71..0000000
--- a/lock-test/src/test/java/com/github/houbb/lock/test/lock/SynchronousQueueDemo.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package com.github.houbb.lock.test.lock;
-
-/**
- * @author binbin.hou
- * @since 1.0.0
- * @see java.util.concurrent.SynchronousQueue
- */
-public class SynchronousQueueDemo {
-}
diff --git a/lock-test/src/test/java/com/github/houbb/lock/test/redis/LockRedisTest.java b/lock-test/src/test/java/com/github/houbb/lock/test/redis/LockRedisTest.java
index 6edf950..f869dc1 100644
--- a/lock-test/src/test/java/com/github/houbb/lock/test/redis/LockRedisTest.java
+++ b/lock-test/src/test/java/com/github/houbb/lock/test/redis/LockRedisTest.java
@@ -1,37 +1,37 @@
-package com.github.houbb.lock.test.redis;
-
-import com.github.houbb.lock.api.core.ILock;
-import com.github.houbb.lock.api.support.IOperator;
-import com.github.houbb.lock.core.bs.LockBs;
-import com.github.houbb.lock.redis.support.operator.JedisOperator;
-import org.junit.Ignore;
-import org.junit.Test;
-import redis.clients.jedis.Jedis;
-
-/**
- * @author binbin.hou
- * @since 0.0.1
- */
-@Ignore
-public class LockRedisTest {
-
- @Test
- public void helloTest() {
- Jedis jedis = new Jedis("127.0.0.1", 6379);
- IOperator operator = new JedisOperator(jedis);
-
- // 获取锁
- ILock lock = LockBs.newInstance(operator).lock();
-
- try {
- boolean lockResult = lock.tryLock();
- System.out.println(lockResult);
- // 业务处理
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- lock.unlock();
- }
- }
-
-}
+//package com.github.houbb.lock.test.redis;
+//
+//import com.github.houbb.lock.api.core.ILock;
+//import com.github.houbb.lock.api.support.IOperator;
+//import com.github.houbb.lock.core.bs.LockBs;
+//import com.github.houbb.lock.redis.support.operator.JedisOperator;
+//import org.junit.Ignore;
+//import org.junit.Test;
+//import redis.clients.jedis.Jedis;
+//
+///**
+// * @author binbin.hou
+// * @since 0.0.1
+// */
+//@Ignore
+//public class LockRedisTest {
+//
+// @Test
+// public void helloTest() {
+// Jedis jedis = new Jedis("127.0.0.1", 6379);
+// IOperator operator = new JedisOperator(jedis);
+//
+// // 获取锁
+// ILock lock = LockBs.newInstance(operator).lock();
+//
+// try {
+// boolean lockResult = lock.tryLock();
+// System.out.println(lockResult);
+// // 业务处理
+// } catch (Exception e) {
+// e.printStackTrace();
+// } finally {
+// lock.unlock();
+// }
+// }
+//
+//}
diff --git a/pom.xml b/pom.xml
index da01491..f912206 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,6 @@
lock-api
lock-core
lock-test
- lock-redis
@@ -34,10 +33,13 @@
1.0.6
- 0.1.161
+
+ 0.1.167
0.0.6
0.0.1
1.1.8
+ 0.0.5
+ 1.4.0
4.12
@@ -57,18 +59,17 @@
lock-core
${project.version}