Solved Is this safe?

Discussion in 'Spigot Plugin Development' started by notjacob1, Feb 9, 2020.

  1. So I have an ArrayList of locations, and I want to set each of them to air. To do that I use this code:
    Code (Text):
    public void clear() {
        locations.parallelStream().forEach(l -> {
    But I've been reading up on streams and I learned that a parallel stream uses multiple threads to run code. I also learned that asynchronous world editing is unsafe, and that is basically using a different thread to run code. So my question is, is parallel streaming unsafe like async for world editing or is it fine to use?
  2. Why wouldn’t it be safe? A whole plugin is dedicated to async world editing

    EDIT: see answer below
    #2 Maxx_Qc, Feb 9, 2020
    Last edited: Feb 10, 2020
  3. no, its not safe.
    no its not. the plugin does not edit the world async. it does a million calculations async and then jumps back on the main thread.
    async chunk loading has become a thing, but no public api exists for it yet, and even then it may not be able to modify chunks async, only load them from disk