Closed coding4z closed 9 years ago
My first observation is incorrect, I was able to recreate the problem with a single subSimon as well, but so far I cannot recreate the problem when using Split.stop() only Split.stop(String subSimon).
incorrect statement: 1) When Split.stop(String subSimon) only uses a single subSimon name the deadlock doesn't appear to occur, only when two or more subSimon names are used.
did not mean to click "close"
Tricky one, seems to be easy to fix, but there are things I don't understand. All threads share the same TEMP stopwatch and call stop(randomNumber) on it. This method eventually synchronizes on the TEMP stopwatch and within that lock tries to create new sub-stopwatch using another lock for EnabledManager and then another one on Stopwatch instance again to update it's children list.
Easy fix was to do the stuff on behalf sub-stopwatch out of the synchronized block on the main stopwatch (TEMP). I can't reproduce any dead-lock then. Originally I was puzzled why:
Then these two things clicked - that clear is what caused the deadlock - because:
CopyOnWriteArrayList
) - but this lock is taken by thread 2 already (here the new instance of TEMP is used, Y, because manager does not know about the X anymore)Fix consists of:
org.javasimon.AbstractSimon#addChild
I opened the problem here and in google code just in case....
What steps will reproduce the problem?
What is the expected output? What do you see instead? Expect this application to run without deadlocking.
What version of the product are you using? On what operating system? javasimon-core-4.0.1 I have run this on both MAC OS X and z/OS both result in the same problem.
Please provide any additional information below. Two observations: 1) When Split.stop(String subSimon) only uses a single subSimon name the deadlock doesn't appear to occur, only when two or more subSimon names are used. 2) When SimonManager.clear() is not issued the deadlock doesn't appear to occur
I have provided two files: 1) My test cases that can recreate the problem. https://code.google.com/p/javasimon/issues/attachmentText?id=130&aid=1300000000&name=SimonThreadTest.java&token=ABZ6GAeoOzda3g7AfVZ5xlNyDUMwLkswqQ%3A1419892900998 2) A thread dump showing the blocked threads and the stack trace of where they are blocked. https://code.google.com/p/javasimon/issues/attachmentText?id=130&aid=1300000001&name=thread+dump.txt&token=ABZ6GAdYWGNdlPijB8WNpGTszOa9AI_7FA%3A1419892900998