Synchronous versus asynchronous tasks

A task can be run either synchronously or asynchronously. Simply put, when a synchronous task is executed, it must be completed before the server can continue running normally. An asynchronous task can run in the background while the server continues to function. If a task accesses the Bukkit API in any way, then it should be run synchronously. For this reason, you will rarely run a task asynchronously. An advantage that an asynchronous task gives is that it can be completed without causing your server to lag. For example, writing data to a save file can be done asynchronously. Later in this chapter, we will modify the Warper plugin to save its data asynchronously. As for the AlwaysDay plugin, we must run ...

Get Building Minecraft Server Modifications - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.