Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > entity beans - using 'sychronized'

Reply
Thread Tools

entity beans - using 'sychronized'

 
 
timasmith@hotmail.com
Guest
Posts: n/a
 
      12-11-2005
Hi,

My entity BMP bean has a cache of data, lets call it encapsulated by my
object 'cache'.

Every now and then I reload the cache - and want to prevent access
during that time (several seconds).

However the rest of time every one can have at it. Here is what I have
come up with - but I think synchronizing every single read is a little
over the top. Is there a cheaper 'read only' synchronization option?
Or a better way to do this without handing the data over to the
container.

public class MyEntity {

private Cache cache = new Cache();

public loadCache() {
synchronized (this) {
cache = getNewCache();
}
}

public String readFromCache() {
synchronized (this) {
return cache.getStringFromCache();
}
}
}

thanks

Tim

 
Reply With Quote
 
 
 
 
Alan Krueger
Guest
Posts: n/a
 
      12-11-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> My entity BMP bean has a cache of data, lets call it encapsulated by my
> object 'cache'.
>
> Every now and then I reload the cache - and want to prevent access
> during that time (several seconds).
>
> However the rest of time every one can have at it. Here is what I have
> come up with - but I think synchronizing every single read is a little
> over the top. Is there a cheaper 'read only' synchronization option?
> Or a better way to do this without handing the data over to the
> container.


http://www.jguru.com/faq/view.jsp?EID=35269

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to relate a SQL based entity with an Object based entity in Entity Framework markla ASP .Net 1 10-06-2008 09:42 AM
handy access to attributes of entity beans from session beans Torsten Schmeissel Java 0 04-29-2005 05:19 PM
Entity beans Tim Java 4 01-26-2004 01:19 PM
Design Question: Session vs. Entity Beans MP Java 2 11-11-2003 07:09 PM
The difference between Session and Entity Beans? <see body> Kabal Java 0 07-22-2003 07:35 PM



Advertisments