If I have 2 synchronized methods and 1 calls the other, what exactly happens?
If those 2 synchronized methods are in a class, and 2 of those classes are created, each of them calling one of their synchronized methods, what would happen?
If those 2 classes extended Thread and were started and each called one of their synchronized methods, what would happens?
After reading the java documentation on synchronization I'm still a little confused...... Are synchronized methods only useful when multiple threads are using the methods? And in regards to the 2nd and 3rd questions, would the calls on the objects methods serialize, having 1 wait for the other to finish with the synchronized function, before it calls it next? I'm just trying to better understand where I would need to use synchronization.
My situation is this: I have a FTP class, and an FXPThread class which uses 2 FTPs instances in order to transfer (FXP) between them. When I try to run a single FXPThread, the transfer works fine. When I try to add a 2nd FXPThread to run simultaneously, both connect fine, but randomly, only one of the threads simply hangs on one of the transfers. I figure there has to be some kind of synchronization issue or some kind of java resource issue with sockets or something, but I cant seem to figure it out...