• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Preliminary test fails! Threads problem

 
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello.
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.
Miguel
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
Mark
 
Miguel Roque
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello.
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.
Miguel
 
You know it is dark times when the trees riot. I think this tiny ad is their leader:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic