This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
Hi: I meet a problem of lock. For example, A,B and C want to book the same ticket at the same time. Then A will book it and B,C are locked. But when the lock is released by A, lockManager will notify all members, B and C. So that, B and C will try to book it at same time. I think, I need to create a FIFO array to store waitting members and let them book ticket in order. Please give me some advice. Thanks. Paul
Paul, That is what wait, and notifyAll in the Object class is for. When you get an object lock,there is a battle for the lock when three client go for it. When A releases the lock it calls notifyAll() and lets B and C fight for the lock. That is the best way to handle it, because it is all handled by the JVM. That is threads at it's greatest. So it is better to use what is already provided for you than trying to reinvent the wheel. I remember when I was a kid programmer I kept trying to reinvent the wheel. You should see how many triangular wheels I have, the most bizarre one is Red and has Big letters on it saying STOP. Mark
Originally posted by Mark Spritzler: ... I remember when I was a kid programmer I kept trying to reinvent the wheel. You should see how many triangular wheels I have, the most bizarre one is Red and has Big letters on it saying STOP.
I wish I could remember when I was a kid programmer! I vaguely recall terms like punch-cards, EBCDIC, and magnetic core. I even remember praying for 16K of core (RAM) instead of the 8K we had to work with. Michael Morris OFP (Old Fart Programmer)
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Well I programmed on a Vic 20 when it had only 4K of memory. and before that was the Commodore Pet and the Trash 80's by Radio Shack. Mark
Joined: Jan 30, 2002
Well I programmed on a Vic 20 when it had only 4K of memory. and before that was the Commodore Pet and the Trash 80's by Radio Shack.
Those guys are state of the art compared to my firsts: the IBM 1130 whose console was a teletype and whose printer was nearly as big as Volkswagen and slower than a one-legged dog; and the IBM 360 "mainframe". You did remind me of the last assembly routine I wrote. It was on the old Trash 80, an interrupt routine for a (now defucnt) Houston Instruments plotter. Michael Morris