Skip to content

Commit 84d2052

Browse files
committed
Use the thread pool for things so its shutdown properly
Fixes #53
1 parent 7013745 commit 84d2052

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

bootstrap/geyser/src/main/java/com/rtm516/mcxboxbroadcast/bootstrap/geyser/MCXboxBroadcastExtension.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ private void restart() {
100100
sessionManager = new SessionManager(this.dataFolder().toString(), logger);
101101

102102
// Pull onto another thread so we don't hang the main thread
103-
new Thread(this::createSession);
103+
sessionManager.scheduledThread().execute(this::createSession);
104104
}
105105

106106
@Subscribe
@@ -112,7 +112,7 @@ public void onPostInitialize(GeyserPostInitializeEvent event) {
112112
config = ConfigLoader.load(this, MCXboxBroadcastExtension.class, ExtensionConfig.class);
113113

114114
// Pull onto another thread so we don't hang the main thread
115-
new Thread(() -> {
115+
sessionManager.scheduledThread().execute(() -> {
116116
// Get the ip to broadcast
117117
String ip = config.remoteAddress();
118118
if (ip.equals("auto")) {
@@ -152,7 +152,7 @@ public void onPostInitialize(GeyserPostInitializeEvent event) {
152152
sessionInfo.setPort(port);
153153

154154
createSession();
155-
}).start();
155+
});
156156
}
157157

158158
private void createSession() {

core/src/main/java/com/rtm516/mcxboxbroadcast/core/SessionManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public void init(SessionInfo sessionInfo, FriendSyncConfig friendSyncConfig) thr
9494

9595
// Create the sub-sessions in a new thread so we don't block the main thread
9696
List<String> finalSubSessions = subSessions;
97-
new Thread(() -> {
97+
scheduledThreadPool.execute(() -> {
9898
// Create the sub-session manager for each sub-session
9999
for (String subSession : finalSubSessions) {
100100
try {
@@ -107,7 +107,7 @@ public void init(SessionInfo sessionInfo, FriendSyncConfig friendSyncConfig) thr
107107
// TODO Retry creation after 30s or so
108108
}
109109
}
110-
}).start();
110+
});
111111
}
112112

113113
@Override

0 commit comments

Comments
 (0)