Making an async task

Discussion in 'Plugin Development' started by TopTobster5, Mar 23, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    TopTobster5

    Hi. I am making a plugin which requires talking to a database. I understand that when I am querying that database, it should be in an async task, but I have never worked with them before. So my questions are:
    1. What is an async task?
    2. How do I use one?
    3. Are there any disadvantages to using one?
    4. Are there any alternatives?

    Thanks in advance for any help!
     
  2. Offline

    Rocoty

    1. An async task is a task or operation that runs in a thread separate from the main server thread. It allows you to perform slow and long operations without halting the server.

    2. You can make an async task by scheduling one with the Bukkit scheduler or a bukkit runnable.

    3. Disadvantages are that you cannot use all of the bukkit api asynchronously without causing issues. You can however schedule a sync task from within an async task.

    4. An Alternative is creating a new thread manually and running it. Same advantages and disadvantages apply.
     
    TopTobster5 likes this.
  3. Offline

    TopTobster5

    Rocoty Ok thanks, is how to make one on the wiki?
     
  4. Offline

    Rocoty

    That I don't know. But there are definitely tutorials on scheduling tasks around here on the forums and elsewhere
     
  5. Offline

    TopTobster5

Thread Status:
Not open for further replies.

Share This Page