Solved Are functions called inside an async task also async?

Discussion in 'BungeeCord Plugin Development' started by SkylixMC, Mar 5, 2020.

  1. Pretty much what the title says. If I run an async task, and then from within that async task call a function outside of it, is that function going to be run async?

    I can not seem to find an asnwer online. To visualize it, here is some code (typing this on a phone so could be wrong). I have tried searching for java, parallel threads as well.

    Code (Text):
    ProxyServer().getInstance().getProxy().getScheduler.runAsync(plugin, () -> {
    // Async task code
    someFunction(parms);
    });

    private static void someFunction(String parms) {
    //Function code
    }
    So the question is, is someFunction() ran on the main thread?
     
  2. SteelPhoenix

    Moderator

    If you have a task you're executing async (on another thread), then no, that task is not run on the main thread.
     
    • Like Like x 1
  3. Great. So just to clearify, in this example, when someFunction() is called from the async task ots also run async?
     
  4. Yes, it will be called async.
     
  5. Thanks guys. Ill mark this solved.