0

I wanted to ask about the efficiency of using AtomicIntegerArray and BitSet, and which one has better performance when used in parallel stream java?

Thank you in advance for your help.

Hakan Dilek
  • 2,178
  • 2
  • 23
  • 35
Carol
  • 13
  • 5
  • This will depend a lot on the use case. You need to be more specific than that. What kind of performance are you interested in? Memory? Runtime? – Hulk Jul 15 '20 at 09:24
  • Also, they are not really comparable semantically, as "A BitSet is not safe for multithreaded use without external synchronization." [JavaDocs for BitSet](https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/util/BitSet.html), while "An int array in which elements may be updated atomically." [AtomicIntegerArray](https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/util/concurrent/atomic/AtomicIntegerArray.html) – Hulk Jul 15 '20 at 09:30
  • Please add a concrete example of what you are trying to do, and explain what kind of performace characteristics you are interested in. – Hulk Jul 15 '20 at 09:34
  • @Hulk Thank you. I want to improve performance (running time) of my algorithm. I want to perform a set of computations for nodes in a network, and schedule them in parallel to do the computations. At each step of my algorithm a specif set of vertices should be scheduled for computation. I need AtomicIntegerArray/BitSet to keep track of such nodes. – Carol Jul 15 '20 at 19:42

0 Answers0