Java threading/volatile
I have a thread: class Foo extends Thread { boolean active = true; public void run() { while(active) { //do stuff } } public void end() { active = false; } public void hibernate() { synchronized(this) { wait(); } } } If another thread calls end() , will Foo immediately see that active is now false ? Specifically, because active isn't volatile , I'm not sure that it will. I initially created end() as a clever way of avoiding volatile, but now I'm unsure that it will actually do what I intend. Additionally, if another thread calls hibernate() , which thread will go to sleep? I'm intending Foo to