Hi, I am using the above code to test my network functionality. When I run the program I notice though if the method makeReservation throws an exception, like, for example, the user has booked the room already, the test does not complete. Is this generally the case with threading, ie. that if 1 thread throws an exception, the whole testing application does not complete correctly and is just suspended? I've very new to threading, but I thought if multiple threads were running and 1 became suspended, the other threads could continue running, or is this an incorrect assumption? In my case, for example, one of the threads, throws an exception in the makeReservation method "User Booked already", but the test is suspended after this. I ran the same type of test for the data layer and got the same error. As I am new to multi-threading, any ideas are welcome. Damn, multi-threading, so fast, but slowing me down.
posted 7 years ago
If the following method is synchronized controller.makeReservation(28,data); then when the exception is thrown the thread is suspended inside that synchronized method and the lock is not relaesed, as a result all waiting threads are blocked.
Thanks for all your reply Nioclas, actually solved the issue, when the user checked if room booked already, I set a flag to try and avoid unlocking, which I shouldn't have. Using the flag for some business implementation exceptions to avoid calling the unlock mechanism in the finally block. Thanks for your time and effort, much appreciated.
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads