Class NanoThread

java.lang.Object
org.nanonative.nano.core.model.NanoThread

public class NanoThread extends Object
  • Field Details

  • Constructor Details

    • NanoThread

      public NanoThread()
    • NanoThread

      public NanoThread(Context context)
  • Method Details

    • context

      public Context context()
    • isComplete

      public boolean isComplete()
    • onComplete

      public NanoThread onComplete(BiConsumer<NanoThread,Throwable> onComplete)
    • await

      public NanoThread await()
    • await

      public NanoThread await(Runnable onDone)
    • run

      public NanoThread run(ExecutorService executor, Supplier<Context> context, ExRunnable task)
    • activeNanoThreads

      public static long activeNanoThreads()
    • activeCarrierThreads

      public static long activeCarrierThreads()
    • waitFor

      public static NanoThread[] waitFor(NanoThread... threads)
      Blocks until all provided NanoThread instances have completed execution. This method waits indefinitely for all threads to finish.
      Parameters:
      threads - An array of NanoThread instances to wait for.
      Returns:
      The same array of NanoThread instances, allowing for method chaining or further processing.
    • waitFor

      public static NanoThread[] waitFor(Runnable onComplete, NanoThread... threads)
      Waits for all provided NanoThread instances to complete execution and optionally executes a Runnable once all threads have finished. If onComplete is not null, it will be executed asynchronously after all threads have completed. This variant allows for non-blocking behavior if onComplete is provided, where the method returns immediately, and the onComplete action is executed in the background once all threads are done.
      Parameters:
      onComplete - An optional Runnable to execute once all threads have completed. If null, the method blocks until all threads are done. If non-null, the method returns immediately, and the Runnable is executed asynchronously after thread completion.
      threads - An array of NanoThread instances to wait for.
      Returns:
      The same array of NanoThread instances, allowing for method chaining or further processing.
    • toString

      public String toString()
      Overrides:
      toString in class Object