• unalivejoy@lemm.ee
      link
      fedilink
      English
      arrow-up
      11
      ·
      edit-2
      10 个月前

      No. ArrayList is thread safe and implements the collections API. Vector doesn’t. Though if you’re using Java, there’s almost no instance where you would want to use a Vector instead of ArrayList.

          • DaPorkchop_@lemmy.ml
            link
            fedilink
            English
            arrow-up
            1
            ·
            10 个月前

            Only if one thread modifies it while another one is iterating over it, if two threads try to modify the list at once there isn’t any kind of synchronization and it really could break your list.

            • unalivejoy@lemm.ee
              link
              fedilink
              English
              arrow-up
              1
              ·
              10 个月前

              For everything else, there’s Collections.synchronizedList(new ArrayList<>())