Package org.nanonative.nano.core.model
Class NanoThread
java.lang.Object
org.nanonative.nano.core.model.NanoThread
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final AtomicLongprotected final Contextprotected final LockedBooleanprotected final List<BiConsumer<NanoThread, Throwable>> static final ExecutorService -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic longstatic longawait()context()booleanonComplete(BiConsumer<NanoThread, Throwable> onComplete) run(ExecutorService executor, Supplier<Context> context, ExRunnable task) toString()static NanoThread[]waitFor(Runnable onComplete, NanoThread... threads) Waits for all providedNanoThreadinstances to complete execution and optionally executes aRunnableonce all threads have finished.static NanoThread[]waitFor(NanoThread... threads) Blocks until all providedNanoThreadinstances have completed execution.
-
Field Details
-
onCompleteCallbacks
-
context
-
isComplete
-
VIRTUAL_THREAD_POOL
-
activeNanoThreadCount
-
-
Constructor Details
-
NanoThread
public NanoThread() -
NanoThread
-
-
Method Details
-
context
-
isComplete
public boolean isComplete() -
onComplete
-
await
-
await
-
run
-
activeNanoThreads
public static long activeNanoThreads() -
activeCarrierThreads
public static long activeCarrierThreads() -
waitFor
Blocks until all providedNanoThreadinstances have completed execution. This method waits indefinitely for all threads to finish.- Parameters:
threads- An array ofNanoThreadinstances to wait for.- Returns:
- The same array of
NanoThreadinstances, allowing for method chaining or further processing.
-
waitFor
Waits for all providedNanoThreadinstances to complete execution and optionally executes aRunnableonce all threads have finished. IfonCompleteis not null, it will be executed asynchronously after all threads have completed. This variant allows for non-blocking behavior ifonCompleteis provided, where the method returns immediately, and theonCompleteaction is executed in the background once all threads are done.- Parameters:
onComplete- An optionalRunnableto execute once all threads have completed. If null, the method blocks until all threads are done. If non-null, the method returns immediately, and theRunnableis executed asynchronously after thread completion.threads- An array ofNanoThreadinstances to wait for.- Returns:
- The same array of
NanoThreadinstances, allowing for method chaining or further processing.
-
toString
-