So I'm having this issue with my HashSet.
I am modyfing it from the Main-Thread and the FX8-Thread and now some Objects were added twice. Anyone know how to resolve this issue? Any help is highly appreciated!
So I'm having this issue with my HashSet.
I am modyfing it from the Main-Thread and the FX8-Thread and now some Objects were added twice. Anyone know how to resolve this issue? Any help is highly appreciated!
HashSet
s are not thread safe. This somewhat older thread has a good discussion of thread safe sets: Different types of thread-safe Sets in Java
I'd start by making sure you're using a thread-safe Set
implementation and then make sure your objects implement hashcode
and equals
methods according to what is described here https://www.geeksforgeeks.org/equals-hashcode-methods-java/