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: 4.1 (javadoc)

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

MAIN USER CLASSES

Buffers messages sent to some output stream until all of those that should be written before are available, so that they all can be written in the correct order. Useful for processing input streams in several concurrent threads when order of response messages must reflect the order of request messages. See a usage example here.

Adapter for a Callable so that it may be passed to Executor.execute(Runnable) and its result accessed using CompletableFuture API.

An ExecutorService that allows to obtain a list of tasks that were still running when an attempt to force terminate was made. 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.

Some helper functions.

A ByteArrayOutputStream that allows to directly access its underlying buffer after the stream was closed.