# tortoise-hare **Repository Path**: kunjs/tortoise-hare ## Basic Information - **Project Name**: tortoise-hare - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 40 - **Created**: 2025-11-20 - **Last Updated**: 2025-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 龟兔赛跑 (Tortoise and Hare Race) 这是一个使用Java多线程实现的经典寓言故事模拟程序。 ## 技术栈 - JDK 17 - Maven ## 特性 - 多线程并发执行:乌龟和兔子使用独立线程运行 - 实时进度显示:命令行持续输出两者的进度 - 速度差异模拟:乌龟稳步前进,兔子速度更快但会休息 - 终点判定:自动检测谁先到达终点并宣布获胜者 ## 运行方式 ### 方法1:使用Maven ```bash mvn clean compile exec:java -Dexec.mainClass="com.example.tortoisehare.TortoiseHareRace" ``` ### 方法2:使用运行脚本 ```bash ./run.sh ``` ## 程序输出格式 程序使用如下格式显示实时进度: ``` T: 10 [-----> ] H: 30 [-----------> ] ``` - T 代表乌龟 (Tortoise) - H 代表兔子 (Hare) - `-` 代表已走过的路程 - `>` 代表当前位置 ## 代码结构 - `TortoiseHareRace.java`: 主程序,包含三个线程(乌龟、兔子、输出)的实现 ## 设计说明 程序使用三个线程: 1. 乌龟线程:以稳定较慢速度前进 2. 兔子线程:以较快速度前进,但偶尔会休息 3. 输出线程:定期显示当前比赛状态