up 线程管理

This commit is contained in:
Color_yr committed 2026-03-27 18:17:49 +08:00
1 parent adbc160397
commit d311b81805
6 files changed
+58 -92

No files matched your search

+6 -8
View File
@@ -81,7 +81,6 @@ public class DataSql {
* 数据库文件
*/
public static File sqlFile;
private static boolean isRun;
/**
* 数据库链接对象
*/
@@ -731,26 +730,24 @@ public class DataSql {
*/
public static void start() {
init();
Thread thread = new Thread(DataSql::run);
isRun = true;
thread.start();
new Thread(DataSql::run).start();
}
/**
* 停止数据库
*/
public static void stop() {
isRun = false;
semaphore.release();
}
private static void run() {
AllMusic.log.data("数据库线程启动");
Runnable runnable;
while (isRun) {
while (AllMusic.isRun) {
try {
semaphore.acquire();
if (!isRun)
return;
if (!AllMusic.isRun)
break;
do {
runnable = tasks.poll();
if (runnable != null) {
@@ -762,5 +759,6 @@ public class DataSql {
e.printStackTrace();
}
}
AllMusic.log.data("数据库线程关闭");
}
}