public static void renderEvent(Event event) {
Runnable runnable = () -> {
try {
Thread thread = GetThreadForAddTargetHUDElements(null, TargetHUDElementsType.HP, TargetHUDTargetHandElementType.LEFT);
Thread thread2 = GetThreadForAddTargetHUDElements(null, TargetHUDElementsType.ARMOR, TargetHUDTargetHandElementType.LEFT);
Thread thread3 = GetThreadForAddTargetHUDElements(null, TargetHUDElementsType.ENTITY, TargetHUDTargetHandElementType.LEFT);
Thread thread4 = GetThreadForAddTargetHUDElements(null, TargetHUDElementsType.SWORD, TargetHUDTargetHandElementType.RIGHT);
ExecutorService executorService = Executors.newFixedThreadPool(4);
List.of(thread, thread2, thread3, thread4).forEach(executorService::submit);
// если забарахлит
boolean awaitTermination = executorService.awaitTermination(60, TimeUnit.SECONDS);
// если true
if (awaitTermination) {
Thread.sleep(1000);
}
} catch (Exception e) {
e.printStackTrace();
}
};
Thread thread = new Thread(runnable);
ExecutorService executorService = Executors.newFixedThreadPool(1);
executorService.submit(thread);
if (executorService.isTerminated()) {
System.out.println("Поток терминировался");
try {
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
public static Thread GetThreadForAddTargetHUDElements(Entity entity, TargetHUDElementsType targetHUDElementsType, TargetHUDTargetHandElementType targetHUDTargetHandElementType) {
Thread threadForAddTargetHUDElements = new ThreadForAddTargetHUDElements(null);
return new ThreadForAddTargetHUDElements(null);
}
public static class ThreadForAddTargetHUDElements extends Thread {
public ThreadForAddTargetHUDElements(Entity entity) {
if (entity == null || entity.isParameter()) {
start();
return;
} else {
run();
}
}
}
private enum TargetHUDElementsType {
HP(null), ENTITY(null), ARMOR(null), SWORD(null);
private boolean BOOLEANHP, BOOLEANENTITY, BOOLEANARMOR, BOOLEANSWORD;
TargetHUDElementsType(String name) {
BOOLEANHP = this.name().equals("HP");
BOOLEANENTITY = !BOOLEANHP && !BOOLEANARMOR && this.name().toLowerCase().equalsIgnoreCase("ENTITY");
}
}
private enum TargetHUDTargetHandElementType {
RIGHT(false), LEFT(true);
private boolean isRightHand;
TargetHUDTargetHandElementType(boolean isRightHand) {
}
}