First, it's the Order class itself that is synchronized, not "these arrays" (though the BoughtList class may also be synchronized, but without the source I can't tell). Order is synchronized because it manages an ArrayList of BLs waiting to be processed and is probably accessed by multiple threads. I recommend going to Sun's site and doing the Threads tutorial as it will explain synchronization.
Originally posted by Alex Mackey:
I have had real trouble accessing the BoughtList from another class, I tried setting up inheritance but this just seemed to give all sorts of errors from the code the tutor gave us to start with, so I dont think the answer lies here. Should it be handled here in the order Class. If someone could explain why these arrays are synchronised that would help, is that something to do with it.
Are you running each of the clients in its own JVM by typing "java <someclass>" in different command windows/shells? If so, then they don't see each other and won't affect each other. These need to be run using a single JVM, probably by writing a class with a main method that creates each of the GUI windows and opening them all.
But I just get a Null pointer exeption. I thought the information in the waiting tray would carry over from the new order method?? Does it not work as the Pick and Cashier Clients are seperate classes that run seperatly?