From 5e7c0a21c962df074316dc2000c51844ad61d86d Mon Sep 17 00:00:00 2001 From: alis-lc <18161057239@163.com> Date: Tue, 8 Feb 2022 22:23:04 +0800 Subject: [PATCH] :sparkles: area transfer --- alis-auu/alis-auu-starter/.gitignore | 33 +++++++++++ alis-auu/alis-auu-starter/pom.xml | 43 ++++++++++++++ .../AlisAuuStarterApplication.java | 13 ++++ .../src/main/resources/application.properties | 1 + .../AlisAuuStarterApplicationTests.java | 13 ++++ .../algorithm/thread/SortPrintThread.java | 59 +++++++++++++++++++ 6 files changed, 162 insertions(+) create mode 100644 alis-auu/alis-auu-starter/.gitignore create mode 100644 alis-auu/alis-auu-starter/pom.xml create mode 100644 alis-auu/alis-auu-starter/src/main/java/org/alis/auu/alisauustarter/AlisAuuStarterApplication.java create mode 100644 alis-auu/alis-auu-starter/src/main/resources/application.properties create mode 100644 alis-auu/alis-auu-starter/src/test/java/org/alis/auu/alisauustarter/AlisAuuStarterApplicationTests.java create mode 100644 datastructure/src/main/java/org/alis/smallcc/algorithm/thread/SortPrintThread.java diff --git a/alis-auu/alis-auu-starter/.gitignore b/alis-auu/alis-auu-starter/.gitignore new file mode 100644 index 0000000..549e00a --- /dev/null +++ b/alis-auu/alis-auu-starter/.gitignore @@ -0,0 +1,33 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ diff --git a/alis-auu/alis-auu-starter/pom.xml b/alis-auu/alis-auu-starter/pom.xml new file mode 100644 index 0000000..df3e7bd --- /dev/null +++ b/alis-auu/alis-auu-starter/pom.xml @@ -0,0 +1,43 @@ + + + 4.0.0 + + + org.alis.auu + alis-auu + sugar + + + + + alis-auu-starter + sugar + alis-auu-starter + spring boot starter + + 11 + + + + org.springframework.boot + spring-boot-starter + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/alis-auu/alis-auu-starter/src/main/java/org/alis/auu/alisauustarter/AlisAuuStarterApplication.java b/alis-auu/alis-auu-starter/src/main/java/org/alis/auu/alisauustarter/AlisAuuStarterApplication.java new file mode 100644 index 0000000..fdaf7c5 --- /dev/null +++ b/alis-auu/alis-auu-starter/src/main/java/org/alis/auu/alisauustarter/AlisAuuStarterApplication.java @@ -0,0 +1,13 @@ +package org.alis.auu.alisauustarter; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class AlisAuuStarterApplication { + + public static void main(String[] args) { + SpringApplication.run(AlisAuuStarterApplication.class, args); + } + +} diff --git a/alis-auu/alis-auu-starter/src/main/resources/application.properties b/alis-auu/alis-auu-starter/src/main/resources/application.properties new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/alis-auu/alis-auu-starter/src/main/resources/application.properties @@ -0,0 +1 @@ + diff --git a/alis-auu/alis-auu-starter/src/test/java/org/alis/auu/alisauustarter/AlisAuuStarterApplicationTests.java b/alis-auu/alis-auu-starter/src/test/java/org/alis/auu/alisauustarter/AlisAuuStarterApplicationTests.java new file mode 100644 index 0000000..230cc0f --- /dev/null +++ b/alis-auu/alis-auu-starter/src/test/java/org/alis/auu/alisauustarter/AlisAuuStarterApplicationTests.java @@ -0,0 +1,13 @@ +package org.alis.auu.alisauustarter; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class AlisAuuStarterApplicationTests { + + @Test + void contextLoads() { + } + +} diff --git a/datastructure/src/main/java/org/alis/smallcc/algorithm/thread/SortPrintThread.java b/datastructure/src/main/java/org/alis/smallcc/algorithm/thread/SortPrintThread.java new file mode 100644 index 0000000..da3b3b7 --- /dev/null +++ b/datastructure/src/main/java/org/alis/smallcc/algorithm/thread/SortPrintThread.java @@ -0,0 +1,59 @@ +package org.alis.smallcc.algorithm.thread; + +import java.util.concurrent.locks.Condition; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; + +/** + * 顺序打印 + */ +public class SortPrintThread { + + public static void main(String[] args) { + + Lock lock = new ReentrantLock(); + + Condition condition1 = lock.newCondition(); + Condition condition2 = lock.newCondition(); + char[] c1="1234567".toCharArray(); + char[] c2="ABCDEFG".toCharArray(); + + new Thread(() -> { + lock.lock(); + try { + for(char c:c1){ + System.out.println(c); + condition2.signal(); + condition1.await(); + } + condition2.signal(); + + } catch (InterruptedException e) { + e.printStackTrace(); + } finally { + lock.unlock(); + } + + + }).start(); + + new Thread(() -> { + lock.lock(); + try { + for(char c:c2){ + System.out.println(c); + condition1.signal(); + condition2.await(); + } + condition1.signal(); + } catch (InterruptedException e) { + e.printStackTrace(); + } finally { + lock.unlock(); + } + + }).start(); + + } + +}