Troncoso
VIP Member
That's not really the proper way to do it, to be honest. It might seem to fix it, and you might not notice the problem, but it's probably still there. A lock is the proper way to do it. The general rule I was told was that if you manipulate the same object/var/whatever, use a lock.
Also, I hope you at least catch for a interrupted exception with that sleep call.
In most situations, yeah, that won't help. But, here, I've already got the synchronized lock...thing, which about does the right job. Putting the thread to sleep just sorts out any remaining conflict.
And yeah, I caught the exception.
If the program was doing any more than literally what it does, I'd need to go further into it. But for the sake of getting this project out of my Easter Break, it gets the job done.