aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Reservation 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 "Reservation problem!" Watch "Reservation problem!" New topic
Author

Reservation problem!

Miguel Roque
Ranch Hand

Joined: Oct 24, 2002
Posts: 126
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
Matt Ghiold
Ranch Hand

Joined: Feb 24, 2002
Posts: 213
Try to make it simpler =). You really don't need a thread going off and doing the registration for you.


-Matt<br /> SCJP2<br /> SCJD
John Smith
Ranch Hand

Joined: Oct 08, 2001
Posts: 2937

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

Joined: Oct 24, 2002
Posts: 126
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reservation problem!