Runnable is used
+ * to create a thread, starting the thread causes the object's
+ * run method to be called in that separately executing
+ * thread.
+ *
+ * The general contract of the method run is that it may
+ * take any action whatsoever.
+ *
+ * @see Thread#run()
+ */
+ @SneakyThrows
+ @Override
+ public void run() {
+ if (0 == methodNumber) {
+ lockTest();
+ } else if (1 == methodNumber) {
+ tryLockTest();
+ }
+ }
+
+ /**
+ * lock方法测试
+ * @param
+ * @return void
+ * @Date 2022/1/28 15:14
+ * @Author hz21056617
+ * @Version V1.0
+ */
+ @SneakyThrows
+ public void lockTest() {
+ try {
+ lock.lock();
+ System.out.println(number);
+ Thread.sleep(500);
+ }
+ finally {
+ countDownLatch.countDown();
+ lock.unlock();
+ }
+ }
+
+ /**
+ * tryLock方法测试
+ * @param
+ * @return void
+ * @Date 2022/1/28 15:13
+ * @Author hz21056617
+ * @Version V1.0
+ */
+ @SneakyThrows
+ public void tryLockTest() {
+ if (lock.tryLock()) {
+ try {
+ System.out.println(number);
+ Thread.sleep(500);
+ }
+ finally {
+ countDownLatch.countDown();
+ lock.unlock();
+ }
+ } else {
+ countDownLatch.countDown();
+ System.out.println("上个线程还没有执行完呢");
+ }
+ }
+}
diff --git a/concurrent/src/main/java/concurrent/reentrantlock/ReentrantLockNonFairTest.java b/concurrent/src/main/java/concurrent/reentrantlock/ReentrantLockNonFairTest.java
new file mode 100644
index 0000000..6e47dfe
--- /dev/null
+++ b/concurrent/src/main/java/concurrent/reentrantlock/ReentrantLockNonFairTest.java
@@ -0,0 +1,91 @@
+package concurrent.reentrantlock;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.SneakyThrows;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
+/**
+ * ReentrantLock 非公平锁依次运行
+ * @ClassName: ReentrantLockNonFairTest
+ * @Date: 2022/1/28 13:48
+ * @author hz21056617
+ * @version V1.0
+ */
+@Data
+@AllArgsConstructor
+public class ReentrantLockNonFairTest extends Thread {
+ static final Lock lock = new ReentrantLock();
+ private Integer number;
+ private CountDownLatch countDownLatch;
+ private Integer methodNumber;
+
+ /**
+ * When an object implementing interface Runnable is used
+ * to create a thread, starting the thread causes the object's
+ * run method to be called in that separately executing
+ * thread.
+ *
+ * The general contract of the method run is that it may
+ * take any action whatsoever.
+ *
+ * @see Thread#run()
+ */
+ @Override
+ public void run() {
+ if (0 == methodNumber) {
+ lockTest();
+ } else if (1 == methodNumber) {
+ tryLockTest();
+ }
+ }
+
+ /**
+ * lock方法测试
+ * @param
+ * @return void
+ * @Date 2022/1/28 15:14
+ * @Author hz21056617
+ * @Version V1.0
+ */
+ @SneakyThrows
+ public void lockTest() {
+ try {
+ lock.lock();
+ System.out.println(number);
+ Thread.sleep(500);
+ }
+ finally {
+ countDownLatch.countDown();
+ lock.unlock();
+ }
+ }
+
+ /**
+ * tryLock方法测试
+ * @param
+ * @return void
+ * @Date 2022/1/28 15:13
+ * @Author hz21056617
+ * @Version V1.0
+ */
+ @SneakyThrows
+ public void tryLockTest() {
+ if (lock.tryLock()) {
+ try {
+ System.out.println(number);
+ Thread.sleep(500);
+ }
+ finally {
+ countDownLatch.countDown();
+ lock.unlock();
+ }
+ } else {
+ countDownLatch.countDown();
+ System.out.println("上个线程还没有执行完呢");
+ }
+ }
+}
diff --git a/concurrent/src/test/java/concurrent/queue/QueueTest.java b/concurrent/src/test/java/concurrent/queue/QueueTest.java
new file mode 100644
index 0000000..6a7e21a
--- /dev/null
+++ b/concurrent/src/test/java/concurrent/queue/QueueTest.java
@@ -0,0 +1,40 @@
+package concurrent.queue;
+
+
+import org.junit.jupiter.api.Test;
+
+import java.util.concurrent.ArrayBlockingQueue;
+
+public class QueueTest {
+ @Test
+ public void ArrayBlockingQueueOffer() throws InterruptedException {
+ ArrayBlockingQueue