Browse Source

fix not created threads

master
gsd 2 years ago
parent
commit
ec5ba8b41a
  1. 5
      src/main/java/app/updates/BaseUpdater.java

5
src/main/java/app/updates/BaseUpdater.java

@ -2,6 +2,7 @@ package app.updates;
import java.util.concurrent.Callable;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executors;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
@ -9,10 +10,10 @@ import java.util.function.Supplier;
public abstract class BaseUpdater {
public void CreateTaskUpdater(Supplier function, int timeout) {
System.out.printf("Create task: %s, update after %d sec\n", function.toString(), timeout / 1000);
CompletableFuture.supplyAsync(() -> {
Executors.newFixedThreadPool(1).submit(() -> {
while (true) {
try {
System.out.printf("Call: %s\n", function.toString());
//System.out.printf("Call: %s\n", function.toString());
function.get();
} catch (Exception err) {
err.printStackTrace();

Loading…
Cancel
Save