Skip to content

Tag: java-threads

Thread-safety of int field in Java

If class has field with int type (not Atomic Integer and without volatile keyword) and all access to this field happens under read/write locks – will this field thread-safe in this case? Or in some moment some thread can see not real value of this field but something from cache? Answer Get answer from @…

Thread not awake when timed wait elapsed in java

I am study wait(long timeout) in java,and in the offcial document I found below description: Some other thread invokes the notify method for this object and thread T happens to be arbitrarily chosen as the thread to be awakened. Some other thread invokes the notifyAll method for this object. Some other thread…

Call to method with a thread inside implies a wait?

I have a method that writes a file and it can be a bit slow. So I did this to avoid blocking the rest of actions: However it still takes a while until things B are executed after things A and I was wondering if I should do this instead: Or, in other words, does calling a method with a