This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Now I am using wait method when a record is locked by other client. But when thread is waitting, client still continue doing next steps, refresh the JTable depend on result of modification. In fact, at this time thread does not work. If I need to return a message to client when wait method run? Thank you. Paul Sun.
Hi Paul, To avoid the problem you describe, you need to make database calls in a background thread. I used the Observer pattern to be notified when a thread completed. Hope this helps, Michael Morris
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Joined: Aug 26, 2002
Hi Michael: Coult you tell me details about how to implement background thread? Thanks. Paul.
Joined: Aug 26, 2002
Hi Michael: I have another question. If you access db by way of running a thread in background, what does client do at that time? show a message or do nothing? :roll:
Joined: Jan 30, 2002
If you access db by way of running a thread in background, what does client do at that time? show a message or do nothing?
It just continues accepting/processing user input. If you have one or more background threads booking, you need to make that until those threads complete, that you don't allow those particular records to be booked again.
Coult you tell me details about how to implement background thread?
My DataFacade implemented Runnable, so when the client wanted to book a flight it went thru something like this:
The DataFacade mapped booking requests to threads so that multiple bookings could occur asynchronously. DataFacade also extended Observable and the object that created the booking threads implemented Observer, so whenever a thread completed DataFacade called setChanged() and notifyObservers() and removed the thread from the map. Hope this helps, Michael Morris