> thread is assigned on creation and we are checking it in run() so > (thread == curThread) seems like it must be true until somehow > implClose() is called : > So why not just check if (thread == null) instead ?
This is because we assign the "thread" in the open() method, not in the constructor. If the user will call open->close->open, then two threads will be created (the first thread should be stopped after the close() was called). > > And when can oldThread will be null ? If someone called stop twice ? If open() was not called. > > And why is there no thread = null assignment in implClose() ? It is there: 1300 Thread oldThread = thread; 1301 thread = null; > Shouldn't you update the test to add this new bug id ? Yes, it should: http://cr.openjdk.java.net/~serb/8178403/webrev.01
