AtomicBoolean, set flag once, necessary? Might a static boolean be ok?
问题 I am setting a flag which is set once by any thread that get to set it. All other threads will at various time, pretty often read this flag repeateadly. Right now I am using an AtomicBoolean, which works fine, but I know that if it is queried quite often it can be considerably slower than plain boolean, ( not sure if this is true ). Would it be thread safe to instead change this to a static boolean? Set the flag to true by whoever gets to do that, in fact all of them might be allowed to set