• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Reservation 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've made the reservation system as follows:
I have a class that asks for the number of seats to reserve. After returning from this class, a thread is created. This thread makes the reservation. After the thread.start() I have a call to a method that refreshes the data to be show in the JTable.
My problem is, when I book a seat, the refresh data method is executed before the thread
The code is as follows:

I've tried with the .isAlive() method from the thread, but this just hangs the program, as the thread is allways alive, even after it has finished the execution!
What is the best way to solve this?
Thanks,
Miguel
 
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try to make it simpler =). You really don't need a thread going off and doing the registration for you.
 
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


My problem is, when I book a seat, the refresh data method is executed before the thread.


Move your "refresh" method to the end of the run() method of the "reserve" thread.
Eugene.
 
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.
Problem solved. Instead of reservation class implementing the runnable interface, it is now a normal class. I've changed the reservation method in the main window so that it creates the thread and implements the runnable as a abstract class and it's here that i call the reserve folowed by the refresh.

Now it works .
I've also made the same for the read of the database (refreshTableData() method).
Thanks,
Miguel
 
Of course, I found a very beautiful couch. Definitely. And this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic