File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Problem with sample multi-threaded network test Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Problem with sample multi-threaded network test" Watch "Problem with sample multi-threaded network test" New topic
Author

Problem with sample multi-threaded network test

Mark O' Sullivan
Ranch Hand

Joined: Aug 17, 2009
Posts: 160

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.
Nicolas Kal
Ranch Hand

Joined: Sep 09, 2009
Posts: 69
Mark,

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.

Regards,
Nicolas


SCJP 6.0 , SBCD (Preparing..),
MSc Enterprise Systems Development, BSc Computer Science
Mark O' Sullivan
Ranch Hand

Joined: Aug 17, 2009
Posts: 160
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with sample multi-threaded network test