Skip to content
Jesse Boyd edited this page Nov 1, 2016 · 2 revisions

Async task

Pretty basic stuff, but this is how you run an async task with the FAWE TaskManager

TaskManager.IMP.async(new Runnable() {
    @Override
    public void run() {
        // Do stuff here?
    }
});

Sync task

With the FAWE TaskManager to you can switch to the main thread (from an async one) and run a task.

// Get a player's inventory from an async thread
// E.g. if the method isn't safe to use async
PlayerInventory inventory = TaskManager.IMP.sync(new RunnableVal<PlayerInventory>() {
    @Override
    public void run(PlayerInventory value) {
        this.value = player.getInventory();
    }
});

When to do this?

  • The method you want to call isn't safe to use async
  • The are performance issues with doing the task async