My question is a bit complicated. Let me try to explain this in full, but if you need more details, feel free to ask me, I will add them.
Recently (through experiments), I found out that if a thread continuously performs work, then something like an integer operation in a while (true) loop, interrupting the thread, does not affect it. The theme continues as nothing happened.
ThreadPoolExecutors are now killed using shutDown () or shutDownNow (). I checked the code for these methods, they use the interrupt () call to kill the stream. So, if all the threads are busy with business, how will the performer be killed? How is it killed, for example, when we use it in spring applications.
One of these artists will look like this:
import java.io.File; import java.io.IOException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; public class Test { public static void main(String[] a) { ExecutorService ex = Executors.newFixedThreadPool(50); for (int i = 0; i < 50; i++) { ex.execute(new Thread() { public void run() { try { File f = File.createTempFile("testfile", "txt"); while (true) { f.canRead(); } } catch (IOException e) {
java multithreading
cheekoo
source share