✨ area transfer
parent
e224fbae0c
commit
5e7c0a21c9
@ -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/
|
@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.alis.auu</groupId>
|
||||
<artifactId>alis-auu</artifactId>
|
||||
<version>sugar</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
|
||||
|
||||
<artifactId>alis-auu-starter</artifactId>
|
||||
<version>sugar</version>
|
||||
<name>alis-auu-starter</name>
|
||||
<description>spring boot starter</description>
|
||||
<properties>
|
||||
<java.version>11</java.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1 @@
|
||||
|
@ -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() {
|
||||
}
|
||||
|
||||
}
|
@ -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();
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue