• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

B&S: Testing Locking

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Everybody !


I am just looking for good ideas/suggestions on testing multi-threaded code. I think I have a decent locking mechnanism ready but want to test it vigorously before going any further. Is there any good literature already out there on testing deadlocks, starvation, race conditions etc.

Ofcourse personal experiences (& lessons learnt) on testing locking would be greatly appreciated.

Thanks
 
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


The above code is almost identical to someone elses posted on this forum.

Notes:

1/ As the code stands it spawns 33*10 threads, this is alot, too many for most RMI implementations, if you replace db with your remote stub and use that it will probably fall over, so reduce the 10 value to 2 for RMI.

2/ The 33 value is the number of rows in your table so you need to modify that.

3/ The above code guarantees a single DB object, you may want to make sure your code guarantees this on its own, depending on your design. Simply make the db non-static to test this.

4/ The code creates a lot of logging! So use java.util.logging or reduce it, or you will likely crash your PC. Also note FINE is not logged by default, you need to do - see below

5/ Add code or manually edit file so that your customer field is equal to "0"

6/ The end result is to that every record should end up customer field == 10*200. If not something is amiss. Also check very carefully that all the other fields are not corrupted, as this code also tests your RAFWrappers thread-safety.

7/ If you don't use cookies it's a simple mod in the code above.

java.util.logging setup if you haven't used it before.
otherwise default uses flippin XML




Have fun
 
Ranch Hand
Posts: 1033
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Udham Singh:
Hello Everybody !


I am just looking for good ideas/suggestions on testing multi-threaded code. I think I have a decent locking mechnanism ready but want to test it vigorously before going any further. Is there any good literature already out there on testing deadlocks, starvation, race conditions etc.

Ofcourse personal experiences (& lessons learnt) on testing locking would be greatly appreciated.

Thanks



You definitely need a multithreaded tester, such as the one Mike posted. Another thing you should do is insert random delays into (or around) your file access code. It is quite possible for locking code to appear to work perfectly when the system is very fast and fall over when it slows down, since this introduces more room for race conditions. Note that most file activity on modern systems is cached by the Operting System and runs very fast, this won't be the case over a network, or if using a conditioned OS as might happen in Sun's testing.
 
A timing clock, fuse wire, high explosives and a tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic