Synchronized Methods problem!
I have an assignment that needs to use synchronized methods, what I have to do is create a supermarket app in Java where I set a favourite item/product's ID and retrieve it however those two methods need to use synchronized methods. Also I am using a GUI, so how do I implement that into two buttons?
e.g. Set Favourte, Retrieve Favourite?
Re: Synchronized Methods problem!
See the following link: Using Synchronized Methods
I presume you need to synchronize the method because of multithreading (you don't mention threads at all)? If so, be careful making calls to a Swing GUI - all processes unless otherwise noted in the API should be placed onto the swing event dispatch thread (see Swing and Threads