Relative Content

Tag Archive for javamultithreadingconcurrency

Is this ThreadPool implementation correct?

I am new to concurrent coding and trying to implement simple ThreadPool by myself. I found this implementation on a learning website(jenkov.com) and it seems to be working fine. However, I think thread and isStopped should be atleast volatile in PoolThreadRunnable class or Atomic variables as they are shared by two threads, the one running the method on the object(where isStopped=true and this.thread.interrupt() is called) and the one in which actual run code is being run(where we do this.thread=Thread.currentThread() and while(!isStopped()). Is my understanding correct or am I missing something?