Olu Shiyan wrote:the 10,000,000 iterations took less than a minute to run
SCJP 6, OCMJD6
Olu Shiyan wrote:C'mon Roel, you got a perfect score man.
Don't forget: high performance solutions will not score better than low performance ones, because performance is not an actual requirement
I think it's not the appropriate topic to start a discussion about that
SCJP 6, OCMJD6
SCJP 6 , OCMJD 6 ,
http://www.robertbenson.ie/
SCJP 6 , OCMJD 6 ,
http://www.robertbenson.ie/
SCJP (1.4 | 5.0), OCJP (6.0), OCMJD
Roel De Nijs wrote:
Sean Keane wrote:so where Roel had something like this:
It finally happened: I got mixed up with the great and wise Roberto Perillo
SCJP (1.4 | 5.0), OCJP (6.0), OCMJD
Sean Keane wrote:Your equal brilliance makes you guys interchangeable anyhow ;-)
Cheers, Roberto Perillo
SCJP, SCWCD, SCJD, SCBCD
SCJP (1.4 | 5.0), OCJP (6.0), OCMJD
SCJP (1.4 | 5.0), OCJP (6.0), OCMJD
Roel De Nijs wrote:Hi Robert,
I fully agree with Pedro: your approach doesn't allow concurrency at all. Methods lock and unlock are completely useless with this approach. A scenario shown by Pedro (with a non-sequential output) should be possible when using the Data class.
Kind regards,
Roel
SCJP 5, SCWCD 5, SCBCD 5
Jonathan Elkharrat wrote:
Roel De Nijs wrote:Hi Robert,
I fully agree with Pedro: your approach doesn't allow concurrency at all. Methods lock and unlock are completely useless with this approach. A scenario shown by Pedro (with a non-sequential output) should be possible when using the Data class.
Kind regards,
Roel
but that's the asked behavior. T2 should go to wait state until T1 is finished.
SCJP 5, SCWCD 5, SCBCD 5
SCJP (1.4 | 5.0), OCJP (6.0), OCMJD
Roel De Nijs wrote:You say you can only increase counter to 100. What happens with your program if you increase the counter to 500 or 1000? Giving us such information is much more important than the modified DataClassTest.
Cheers, Roberto Perillo
SCJP, SCWCD, SCJD, SCBCD
Cheers, Roberto Perillo
SCJP, SCWCD, SCJD, SCBCD
Andre Roodt wrote:I wasn't sure whether to fix this in the data class or in the code that calls the method in the data class. I eventually decided to fix it in the Data class where I handle the exception for the sake of the exam criteria stating that the data class must not cause deadlocks.
Roel De Nijs wrote:
Andre Roodt wrote:I wasn't sure whether to fix this in the data class or in the code that calls the method in the data class. I eventually decided to fix it in the Data class where I handle the exception for the sake of the exam criteria stating that the data class must not cause deadlocks.
In my opinion that's not the right place to solve the issue! You should simply put the code that calls Data class methods in a try(-catch)-finally and unlock the record in the finally-block. That's correct use of the API (Data class). Making the Data class responsible for this multi-threaded issue is an example of bad design.
Just my 2 cents.
CISSP, CCSP, CSSLP, SSCP, CASP+, Security+, OCP Java 17 Developer | https://bjdelacruz.dev
Bj Peter DeLaCruz wrote:If anyone is interested in testing the locking mechanism in the Data class using my test code, I can post it here or give you a link to my Github account where I host it.
CISSP, CCSP, CSSLP, SSCP, CASP+, Security+, OCP Java 17 Developer | https://bjdelacruz.dev
No matter. Try again. Fail again. Fail better. This time, do it with this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|