Skip to content

Hey there! If you like my work, you can support me by sponsoring me on GitHub. Thanks! ❤

Sponsor me
on GitHub

@Async

To execute a command asynchronously, you can use the @Async annotation.

Async command execution

Java
@Command(name = "async-command")
public class Example {

    @Async
    @Execute
    void execute() {
        System.out.print("This message is triggered asynchronously!");
    }
}

IMPORTANT

The command will be executed in an asynchronous thread defined by scheduler.

Async argument parsing

You can parse arguments asynchronously as well. To do this, you need to use the @Async annotation on the argument:

Java
@Command(name = "user")
public class UserCommand {

    @Execute(name = "load")
    void execute(@Async @Arg User argument) {
        System.out.print("This message is triggered in the main thread!");
    }
}

WARNING

The @Async annotation on the argument will parse the argument asynchronously, but the command will be executed in the main thread.

Made by LiteDevelopers and Contributors with ❤️