In Minecraft 1.8, packet handling was made multithreaded, packets are handled in a networking thread separate from the Server and Client threads.
This introduces concurrency issues when you want to access things such as worlds or entities from a packet handling method. For this reason, addScheduledTask methods have been added which allows you to add Callables to a queue, and these Callables get processed every tick in the Client or Server thread, so they can opeate thread-safely.
Rather than doing your stuff directly in the packet handling method, you would enqueue a Callable which does it, which will get executed synchronously at the next tick.
Now, how does Mojang utilize this meachanism for their own packets? Take a look at PacketThreadUtil:
Java:
if (!p_180031_2_.isCallingFromMinecraftThread())
{
p_180031_2_.addScheduledTask(new Runnable()
{
private static final String __OBFID = "CL_00002305";
public void run()
{
p_180031_0_.processPacket(p_180031_1_);
}
});
throw ThreadQuickExitException.field_179886_a;
}
Yup, that's right. It checks if the packet handling method is called from the correct thread, if not it enqueues it and throws a "ThreadQuickExitException" to terminate further processing of the packet...blergh
Mojang please, Java is not Ruby