--- a/net/minecraft/Util.java +++ b/net/minecraft/Util.java @@ -95,6 +95,22 @@ private static final TracingExecutor BACKGROUND_EXECUTOR = makeExecutor("Main"); private static final TracingExecutor IO_POOL = makeIoExecutor("IO-Worker-", false); private static final TracingExecutor DOWNLOAD_POOL = makeIoExecutor("Download-", true); + // Paper start - don't submit BLOCKING PROFILE LOOKUPS to the world gen thread + public static final ExecutorService PROFILE_EXECUTOR = Executors.newFixedThreadPool(2, new java.util.concurrent.ThreadFactory() { + + private final AtomicInteger count = new AtomicInteger(); + + @Override + public Thread newThread(Runnable run) { + Thread ret = new Thread(run); + ret.setName("Profile Lookup Executor #" + this.count.getAndIncrement()); + ret.setUncaughtExceptionHandler((Thread thread, Throwable throwable) -> { + LOGGER.error("Uncaught exception in thread " + thread.getName(), throwable); + }); + return ret; + } + }); + // Paper end - don't submit BLOCKING PROFILE LOOKUPS to the world gen thread private static final DateTimeFormatter FILENAME_DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd_HH.mm.ss", Locale.ROOT); public static final int LINEAR_LOOKUP_THRESHOLD = 8; private static final Set ALLOWED_UNTRUSTED_LINK_PROTOCOLS = Set.of("http", "https"); @@ -136,7 +152,7 @@ } public static long getNanos() { - return timeSource.getAsLong(); + return System.nanoTime(); // Paper } public static long getEpochMillis() { @@ -537,7 +553,7 @@ public static , V> EnumMap makeEnumMap(Class enumClass, Function mapper) { EnumMap enumMap = new EnumMap<>(enumClass); - for (K enum_ : (Enum[])enumClass.getEnumConstants()) { + for (K enum_ : enumClass.getEnumConstants()) { // Paper - decompile error enumMap.put(enum_, mapper.apply(enum_)); }