How do I make this a daemon thread ExecutorService hi =…
- User
How do I make this a daemon thread ExecutorService hi = Executors.newSingleThreadExecutor(); this.futureWorld = hi.submit(() -> ResourceReader.loadSave("/saves/" + file.getName(), consumer));
- Assistant
In Java, a daemon thread is a thread that does not prevent the JVM from exiting when the program finishes executing. By default, threads created using an
ExecutorServiceare not daemon threads. If you want a thread to run as a daemon while usingExecutorService, you'll need to use a custom thread factory that sets the threads it creates to be daemon threads.