Skip to content

morgwai/java-utils

Repository files navigation

Java utils

Some utility classes.
Copyright 2021 Piotr Morgwai Kotarbinski, Licensed under the Apache License, Version 2.0.

latest release: 5.1 (javadoc)

Note: from version 2.0, java.util.logging utilities have been moved to a separate repo.

MAIN USER CLASSES

Buffers messages until all of those that should be written before to the underlying output stream are available, so that they all can be written in the desired order. Useful for processing input streams in several concurrent Threads when the order of the resulting outbound messages must reflect the order of inbound messages. See a usage example here.

Adapter for a Callable that allows to pass it to Executor.execute(Runnable) and access its results using CompletableFuture API.

ExecutorService that allows to obtain a List of currently running tasks. Useful for monitoring or debugging which tasks got stuck and prevented clean termination. 2 implementations are provided: TaskTrackingThreadPoolExecutor extending ThreadPoolExecutor and ScheduledTaskTrackingThreadPoolExecutor extending ScheduledThreadPoolExecutor.

Utilities to await for multiple timed blocking operations, such as Thread.join(timeout), ExecutorService.awaitTermination(...) etc. See a usage example here.

ByteArrayOutputStream that allows to directly access its underlying buffer (without copying) after the stream was closed.