I’m currently in the process of writing the documentation for the SchedulerService, and as such I was looking to compile a list of all the thread-safe things you can do inside an asynchronous thread. So far, the only parts of Minecraft that are thread-safe that I can find are:
since Minecraft’s singlethreaded, there’s little else you can do with Minecraft on an async thread; if you really need to do work asynchronously you should just do all the parts on the thread that don’t touch the API, and then tell it to register a task with the scheduler to indicate its done or something.
I though SpongeAPI uses the javax.annotation.concurrent.ThreadSafe to mark thread-safe methods?
If you are writing the documentation that covers asynchronous execution, it is probably a good idea to also add links to popular concurrency tutorials such as the official tutorial or Java Concurrency in Practice by Brian Goetz.
Coincidentally, @zml and I were chatting about this after SoS V. He mentioned that sponge’s built-in Permissions handling is also thread safe. Hope that helps.
Depending on the implementation, event handling looks like it was attempted to be made thread-safe.
I suggest that the thread safety requirements of each class be evaluated and documented by the API authors because synchronization policies differing based on implementation is definitely not a good thing.
I absolutely agree, which is a part of the reason I made this forum post, because there is usually a bit of a divide between those writing the API/Implementation and those writing the docs.