-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Entities + Threads
PostPosted: Wed Feb 03, 2010 4:25 pm 
Beginner
Beginner

Joined: Wed Dec 10, 2008 5:59 am
Posts: 47
Hi,

I could need a little clarification on the area of entities and threads. I'm experimenting with a desktop application, which purpose is to manage my personal DVD collection. I'm keeping things simple, and i do not use any fancy transfer objects or the like.

Now, i've got a DvdServices class which returns a collection of Dvd instances - each representing a DVD in my collection. To be a little more specific, the DvdServices class manages the transactions and sessions, but the DvdDao class is the place where the actual database querying is going on. This collection is handed over to my GUI, which displays the DVD's in a list.

One feature of this software is to automatically find ratings for each DVD by querying an external service. This means that for each Dvd instance, i need to download one or more available ratings from the external service, update the Dvd instance with the rating and persist all changes. However, as with any GUI application, i need to display some progress details. However, updating the progress bar does not work very well if i do the external DVD rating querying on the event dispatch thread. So, i will to do both external querying and database operations on another thread.

That involves handing the Dvd instances over to another thread, retrieving ratings and updating those objects there, and getting them back in a new state. I've recently read "Concurrency In Practice" by Goetz, and one of the main things i got from that book is that there are a LOT of potential pitfalls lying here. However, what i would do is to synchronize all accessors and mutators on the object to ensure thread visbility. There will never be any potential issues with two different processes updating the objects at the same time. The only issue will be to maintain thread visibility, so that the state of the objects are properly maintained.

I would LOVE to hear any thoughts on this, and not least if it makes sense and adheres to what one could call "best practices". I'm doing this project mostly to learn how to do things right, so if anyone has been through anything similar - then i'd be really happy to hear how you did it.

Thanks!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.