I’m trying to access my main thread from my secondary thread… But that is not going that well right now.
What I’m trying to do… Is sending a console command from the thread that is doing the work. But I do not have that much experience with threading… If there is someone here that can point me in the right direction or show me an example. That would be really great.

And I’m using Sponge scheduler to run the task async.

Error from console:

[00:28:00] [pool-3-thread-1/FATAL] [Sponge]: stopTiming called async for playerCommand [00:28:00] [pool-3-thread-1/ERROR] [STDERR]: java.lang.Throwable [00:28:00] [pool-3-thread-1/ERROR] [STDERR]: at co.aikar.timings.TimingHandler.stopTiming( [00:28:00] [pool-3-thread-1/ERROR] [STDERR]: at net.minecraft.command.CommandHandler.handler$onExecuteCommandReturn$0(SourceFile:91) [00:28:00] [pool-3-thread-1/ERROR] [STDERR]: at net.minecraft.command.CommandHandler.func_175786_a(SourceFile:83) [00:28:00] [pool-3-thread-1/ERROR] [STDERR]: at org.spongepowered.common.command.MinecraftCommandWrapper.tryExecute( [00:28:00] [pool-3-thread-1/ERROR] [STDERR]: at org.spongepowered.common.command.MinecraftCommandWrapper.process( [00:28:00] [pool-3-thread-1/ERROR] [STDERR]: at consoleSender.sendCommand( [00:28:00] [pool-3-thread-1/ERROR] [STDERR]: at backup.backupWork( [00:28:00] [pool-3-thread-1/ERROR] [STDERR]: at backup.lambda$runAsyncNow$1( [00:28:00] [pool-3-thread-1/ERROR] [STDERR]: at org.spongepowered.api.scheduler.Task$Builder.lambda$execute$12( [00:28:00] [pool-3-thread-1/ERROR] [STDERR]: at org.spongepowered.common.scheduler.SchedulerBase.lambda$startTask$570( [00:28:00] [pool-3-thread-1/ERROR] [STDERR]: at java.util.concurrent.Executors$ Source) [00:28:00] [pool-3-thread-1/ERROR] [STDERR]: at Source) [00:28:00] [pool-3-thread-1/ERROR] [STDERR]: at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [00:28:00] [pool-3-thread-1/ERROR] [STDERR]: at java.util.concurrent.ThreadPoolExecutor$ Source) [00:28:00] [pool-3-thread-1/ERROR] [STDERR]: at Source)


public static void runAsync() {
    int interval = Config.getTimerInterval();

    Scheduler schedula = Sponge.getScheduler();
    Task.Builder taskBuilder = schedula.createTaskBuilder();

    Task task = (Task) taskBuilder.execute(() -> backupWork()).async().delay(TimeUnit.MINUTES.toMillis(interval), TimeUnit.MILLISECONDS)
            .interval(TimeUnit.MINUTES.toMillis(interval), TimeUnit.MILLISECONDS)
            .name("AutoBackup - backup process has started!").submit(autoBackup.getAuto());

From my command sender. I believe that is from you… From my last post.

public static void sendCommand(String command){
    //Get console
    CommandSource console = autoBackup.console;
    java.util.Optional<? extends CommandMapping> optCommandMapoping = autoBackup.cManager.get(command, console);
    if (optCommandMapoping.isPresent()){
        CommandMapping mapping = optCommandMapoping.get();
            mapping.getCallable().process(console, "");
        }catch (CommandException e){


If you could show us the code you are using it would be a big help.

I have added the code.

Okay, so what you want to do is run the work task, and then from in that work task, schedule a non-async task with no delay in which you call the command.


  1. Start worker thread
  2. Determine command
  3. From within worker thread, construct task to execute the command
  4. Start that task as a non-async, no-delay, task
  5. ???
  6. Profit!

I do this all the time when I’m making either a server query or processing some data, and then I return the main thread to execute/display the result. If done right, it works perfectly.

Oh wow… Well that worked :smiley:
Thanks! Didn’t think about actually starting a new TASK from a task… That is not async… :smiley: