初始化 Maven 项目并添加示例代码

- 新增 pom.xml,引入 lunar 依赖,Java 版本 25
- 新增 .gitignore 忽略常见 IDE 与构建产物
- 新增 Main 示例入口
- 新增 LunarSample 阴历转换示例
- 新增 VirtualThreadSimpleBenchmark 虚拟线程与平台线程池对比示例
This commit is contained in:
2026-10-24 15:59:38 +08:00
commit 9a6cc56927
5 changed files with 140 additions and 0 deletions

41
.gitignore vendored Normal file
View File

@@ -0,0 +1,41 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
.kotlin
### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store
/.idea/

23
pom.xml Normal file
View File

@@ -0,0 +1,23 @@
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ttstd</groupId>
<artifactId>MavenUtils</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>cn.6tail</groupId>
<artifactId>lunar</artifactId>
<version>1.7.7</version>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>25</maven.compiler.source>
<maven.compiler.target>25</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>

View File

@@ -0,0 +1,15 @@
package com.ttstd;
import com.nlf.calendar.Lunar;
public class LunarSample {
public static void main(String[] args){
//今天
//Lunar date = new Lunar();
//指定阴历的某一天
Lunar date = new Lunar(1986,4,21);
System.out.println(date.toFullString());
System.out.println(date.getSolar().toFullString());
}
}

View File

@@ -0,0 +1,17 @@
package com.ttstd;
//TIP 要<b>运行</b>代码,请按 <shortcut actionId="Run"/> 或
// 点击装订区域中的 <icon src="AllIcons.Actions.Execute"/> 图标。
public class Main {
static void main() {
//TIP 当文本光标位于高亮显示的文本处时按 <shortcut actionId="ShowIntentionActions"/>
// 查看 IntelliJ IDEA 建议如何修正。
IO.println(String.format("Hello and welcome!"));
for (int i = 1; i <= 5; i++) {
//TIP 按 <shortcut actionId="Debug"/> 开始调试代码。我们已经设置了一个 <icon src="AllIcons.Debugger.Db_set_breakpoint"/> 断点
// 但您始终可以通过按 <shortcut actionId="ToggleLineBreakpoint"/> 添加更多断点。
IO.println("i = " + i);
}
}
}

View File

@@ -0,0 +1,44 @@
package com.ttstd;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
public class VirtualThreadSimpleBenchmark {
private static final int TASK_COUNT = 10_000;
private static final int IO_DELAY_MS = 50;
public static void main(String[] args) throws Exception {
// 1. 平台线程池(常见配置)
test("Platform FixedThreadPool(200)",
Executors.newFixedThreadPool(200));
// 2. 虚拟线程(每个任务一个虚拟线程)
test("Virtual Threads",
Executors.newVirtualThreadPerTaskExecutor());
}
private static void test(String name, ExecutorService executor)
throws InterruptedException {
System.out.println("\n=== " + name + " ===");
long start = System.currentTimeMillis();
for (int i = 0; i < TASK_COUNT; i++) {
executor.execute(() -> {
try {
Thread.sleep(IO_DELAY_MS); // 模拟 I/O 阻塞
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
});
}
executor.shutdown();
executor.awaitTermination(1, TimeUnit.HOURS);
long cost = System.currentTimeMillis() - start;
System.out.println("Total time: " + cost + " ms");
}
}