I am trying to get my locking to work, using synchronized, wait and notifyAll. I had been calling wait inside lock() but it hung my application. (Waiting forever). I have never written multi-threaded code before, and this is pretty confusing. From searching and reading lots of old posts, I am pretty sure I synchronize on my Map of locks, and only call notifyAll from unlock(). I am wondering if I even need to wait? I have the "consume no CPU cycles" in my instructions, so I'm pretty sure setting a timeout is a bad idea, and probably automatic failure. I also understand the notifyAll might consume a few (trivial few), but people generally have passed with full marks and used it. Thanks in advance.
I had a logic error in my code. I had everything you just told me, but this statement: I figured the lock wouldn't be in there yet, because I hadn't put it in there. I guess that is the whole point It works now, at least not throwing any exceptions and hanging. I guess I need to thread thrash it, now.
it took me 3-4 weeks to make my Data-implementation (i have fulltime job, so only weekends and evenings), but because i see it as the most important part, i took my time to ensure everything is working as expected (and javadoc'ing everything is also time consuming). I made also a unit test to verify if each method of the data class is doing what the javadoc says (including all possible exceptions that can be thrown). and the lock/unlock methods i tested using the test classes of roberto perillo.
I got a test harness off this forum. I will grab Roberto's as well. He got 80/80 in Locking. He also synchronized all of Data (I did that, too). I am lucky, I have down time at work right now, so I am working on it at work, and have made major progress this week. I should be getting another project tomorrow or Monday. I don't have time to work on it at home because I am working on my BS degree in Information Systems and my free time is spent working on that.
Anne Crace wrote: He also synchronized all of Data (I did that, too).
I'm not that lucky at work, i even have to travel 1.5 - 2h each day, so my time during the week is very limited, but it has a high priority, because i've the assignment already from Q2 2007 and all other projects have lower priority, i hope to finish at the beginning of april
which test harness are you using?
good luck with your assignment (and your bs degree)
I used this one: Take this Testing Tool. Be sure to note the second post. There is a small logic error that needs to be fixed in the original code. I found Roberto's in the process of looking for this one I have had mine out since Spring of 2006, so it is a priority for me, too!
Anything worth doing well is worth doing poorly first. Just look at this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!