Interface ModThread

All Superinterfaces:
Executor

@NonExtendable public interface ModThread extends Executor
The mod's own platform thread, zf-mod-<id>: runs one task at a time, in the order they were submitted. ZomboidForge shuts it down when the server stops; tasks submitted after that are rejected with a RejectedExecutionException. It must not touch game objects; that goes through main().
  • Method Details

    • execute

      void execute(Runnable task)
      Runs task on the mod thread. An exception it throws is logged with the mod's id.
      Specified by:
      execute in interface Executor
    • submit

      <T> CompletableFuture<T> submit(Callable<T> task)
      Runs task on the mod thread; the future completes with its result or exception.
    • schedule

      ScheduledFuture<?> schedule(Runnable task, Duration delay)
      Runs task once after delay. An exception it throws is logged.
    • scheduleAtFixedRate

      ScheduledFuture<?> scheduleAtFixedRate(Runnable task, Duration initialDelay, Duration period)
      Runs task after initialDelay, then every period, measured from the start of each run. A run that throws is logged and ends the schedule.
    • scheduleWithFixedDelay

      ScheduledFuture<?> scheduleWithFixedDelay(Runnable task, Duration initialDelay, Duration delay)
      Runs task after initialDelay, then again delay after each run finished. A run that throws is logged and ends the schedule.
    • isModThread

      boolean isModThread()
      Whether the calling thread is this mod thread.