File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Preliminary test fails! Threads problem 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 "Preliminary test fails! Threads problem" Watch "Preliminary test fails! Threads problem" New topic

Preliminary test fails! Threads problem

Miguel Roque
Ranch Hand

Joined: Oct 24, 2002
Posts: 126
I'me starting to make some tests so that I can test the server and the reservation mechanism. I have the lock manager as follows:

As i've used a factory, i get a diferent client number, so here i don't have any problem
The main problem for now is that i've build a small test program that makes seat reservation in one flight. The program is as follows:

And the code to make the seat reservation:

The big problem is when i run the test program with this 5 clients, it only reserves 2 seats
After the lock and unlock method in the server i've put a print to show the result, and the problem cames here. The output in the server is as follows:

I'm with all this. Where is the problem?
Thanks for your help.
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

First is a little thing. You do not need the break; lines in the LockManager.
Second, it appears that there are no exceptions being thrown, else you would have ahd a stack trace. So that means you need to debug your booking method, as you don't show your test thread code.
The way I like to debug is longer winded than some tools that are out there, but I use the old "System.out.println("I am here in the code");"
Then you can see how far the code gets. If you are using 1.4 then you can add assertions to your code to make sure that the data/variables are set to where you would expect them to be.
Sorry I couldn't be of more help to you, but sometimes debugging is the best learning tool, and I wouldn't want to lose that great tool.

Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
Miguel Roque
Ranch Hand

Joined: Oct 24, 2002
Posts: 126
Just seen the error ! I was using the data from the find method to make the reservation .
I was not following the Lock->Read->Modify->Unlock .
By the way. I like to use the tipical debug System.out.println("Here I am"); i'ts the best debug tool that I know .
Thanks for the help.
I agree. Here's the link:
subject: Preliminary test fails! Threads problem
It's not a secret anymore!