This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
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
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.
Joined: Oct 24, 2002
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