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 @…
Tag: java-threads
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
How to execute selenium script in a lot of threads?
I like to test my site in a lot of threads. But when I trying to do that, I see one problem. All motions when I like are happening in last opened window. So, the first window just stuck in background. I really don’t understand why it happens. You can see it here. After that the code has run, the
Running a compiler in parallel with java.utils.concurrent
I am making a compiler for a language in Java and I want it to compile many files in parallel. I have my class Compiler.java that has the constructor Compiler(String fileName) and the method compile() So to compile a single file in my main all I do is : What I want to do is for a list of files
isInterrupted() still returns “false” even after the Thread.State is “TERMINATED” in Java’s Thread – why?
When thread gets terminated (Thread.State.TERMINATED) it is still not interrupted. Why? I found this, and I found this, but neither answers my question.I have tried this out on OpenJDK 11 and Oracle JDK 16 – no difference, same result. I have been working with Java for more than 10 years now, and multit…
Ideas for listing files, directories, sub files & sub directories without recursion in ftp server
I’m trying to produce file listing of a given directory and it’s sub directories in a ftp server. The server works fine, and I have been successfully able to produce the file listing of the current directory. When I try to list the subdirectories and their files is where it gets complicated. I was…
Java: is it possible to create a garbage-collectable object that includes an internal heartbeat thread?
Quick question: Is is possible to create a class such as it contain an internal infinite thread (heartbeat) and its objects are automatically garbage collected? Long question: I intend to create a class that includes an internal infinite background thread (such as a heartbeat). Although, the objects of this c…