Do I need to synchronize a singleton just for reads?

Hello forum. Here's my situation: I keep config data for pages on my website in an XML file, I load said XML file in a startup servlet, creating a JDOM Document object, accessed by a singleton.
Every time a page is loaded, the page accesses this Document object via the singleton, sees whether the page is secure, which template it should use, a bunch of stuff.
Now, because the Document object is created when the context is started, and is never written too, only read, do I need to synchronize it?
I read "Threading lightly, Part 1: Synchronization is not the enemy," on ibm.com (http://www-128.ibm.com/developerworks/java/library/j-threads1.html) in hopes of answering my own question, and the most relevant paragraph states:
"If you are writing data that may be read later by another thread, or reading data that may have been written by another thread, then that data is shared, and you must synchronize when accessing it."
But does my scenario fit? Yes I'm writing data that will be read by another thread, but no thead is accessing this data until the context is fully loaded and the object is fully instantiated. The object is not being written to by threads asynchronously... I just run the risk of it being read at the same time. Do I need to synchronize? If so... having synchronized variables in a servlet environment is bad, so what other approach should I take?
Thanks for your help.

But does my scenario fit? Yes I'm writing data that
will be read by another thread, but no thead is
accessing this data until the context is fully loaded
and the object is fully instantiated. The object is
not being written to by threads asynchronously.If all the writing is complete before any of the reading starts, then there's no need to synchronize the reading.
.. I
just run the risk of it being read at the same time.There's no risk in multiple concurrent reads.
Do I need to synchronize? If so... having
g synchronized variables in a servlet environment is
bad, so what other approach should I take?Couple minor points:
* You don't have synchronized variables. You have synchronized blocks and methods.
* Using synchronization in a servlet context isn't in and of itself necessarily bad. Having multiple requests sync on the same lock can hurt response time, so try to avoid it, and if you must do it, keep the critical sections as small as possible.

Similar Messages

  • Laptop needs an "Aperture Lite"? Just  for reviewing projects.

    I am never going to run Aperture on my powerbook or older
    computers. I do need to show clients their weddings.
    Apple! Any chance of an Aperture Lite that can view projects only on
    our 1.25 12inch powerbook? I don't need the conversions or other
    tools that drag down the speed. I do need to show client and would
    love the same interface for that purpose.
    Sure would be nice to see a light table, book design and review
    interface on our powerbook.

    There are many software programs that have lite
    versions. I don't see why
    Aperture can't also just for all of us with older
    powerbooks and computers that can meet the high end
    requirements. Aperture could read the powerbook
    requirements and install a lite version for viewing
    only. A lite version that is not so power hungry
    would be a great idea for client review. A lite
    version could read the raw files and display proxy
    that would open fast, show a light table or even have
    the book design feature.
    I was thinking out loud about what would be nice for
    those of us with the older powerbooks that can not
    install or use Aperture. A trimmed down version
    would still be valuable in the way we want to use it
    as a library and for showing clients our wedding
    galleries.
    iPhoto or Preview would work for this and they both cost nothing, actually even on my iBook Aperture is very usuable for browsing and proofing.
    iBook G4 12" 1.33 1GB ram, iMac 233   Mac OS X (10.4.3)  

  • Profile for authorizations just for reading?

    Hello,
    is there an already existing profile just your displaying? Like the SAP_ALL just reading?
    regards
    Florian

    These are the various display profiles which I could find in my system.
    A_ANZ                  FI-AA Asset Accounting: Complete display authorization
    F_ANZ                   FI Display Authorization Model Profile
    F_BKPF_KANZ      FI authorizations for displaying vendor documents
    F_KREDI_BANZ     FI Auth. for Displaying Vendors (Financial Accounting Data
    F_SAKO_ANZ        FI authorizations for displaying G/L accounts.
    Regards
    Aravind
    Message was edited by:
            Aitipamula Aravind

  • Do I need to Synchronize session connection??

    I am working on a project in which requires sending out emails.
    Multiple users may send out emails at the same time by using same email account and session. Question is do I need to synchronize this or just let mail server handle this concurrency. Or session's getDefaultsession method have already considered this? Looking forward to your answer!! Best regards,

    Multiple users may send out emails at the same time by using
    same email account and session.Don't do that. Each thread should have its own session. Otherwise you'll have chaos. Sure, you could synchronize so the threads take turns using a single session, but if you do that there isn't much point in having separate threads, since 99% of the time they will be lining up to use the session.
    However if those "users" are running in separate JVMs, perhaps even on separate computers, then the question doesn't arise. They would automatically have their own sessions.

  • PC hard drive died and I have replaced it.  Need to import the music on my iPod, but get a message that it's synced with another library (old hard drive).  How do I import the music onto new hard drive? Senuti's just for macs.No old hard drive to copy.

    My PC hard drive died and I have replaced it.  Need to import the music on my classic iPod, but get a message that it's synced with another library (old hard drive).  How do I import the music onto the new hard drive? Senuti (one respondent's suggestion) is just for macs. I have no old hard drive to copy to the new hard drive (another respondent's suggestion.)

    See this older thread from another forum member Zevoneer on different ways to copy music from your iPod back to your PC.
    https://discussions.apple.com/thread/2417169?start=0&tstart=0
    B-rock

  • Would Like to Get Report of Daily Emails In and Out from Members to a DL Exchange version : 2007 I am the supervisor for the group and want to quantify this information. I do not need to see the content, just quantity is it possible ?

    Would Like to Get Report of Daily Emails In and Out from Members to a DL
    Exchange version : 2007
    I am the supervisor for the group and want to quantify this information. I do not need to see the content, just quantity
    is it possible ?

    Well, distribution groups don't really have a concept of "in" or "out". They only serve to distribute messages sent to them -- unless you're asking to know who was a member of the distribution group at the time a message was sent to the DL.
    Message tracking logs hold the information you want, though. You'd have to look for EXPAND events that reference the distribution group and take the sender's e-mail address from that event. If the DL is a simple one that's not a member of any other groups
    you could also look for RECEIVE events sent to the e-mail address of the group and get the sender's name from that event.
    You can use Powershell extract the rows of data from the logs, but you'll have to write the code to get the data out of those rows and into a format you want. Perhaps LogParser could be useful in place of Powershell?
    --- Rich Matheisen MCSE&I, Exchange MVP

  • HT204266 I erase all application of my iphone 4 with erase restore and now it's in restore mode. Now is there any way to restore my iphone without backup. Please help me. I have no need my previous file i just want my i phone ok and work smoothly as new p

    Hi,
    I erase all application of my iphone 4 with erase restore without any backup & i also lose the product serial number. Now it's in restore mode. Now is there any way to restore my iphone without backup. Please help me. I have no need my previous file I just want my iphone4 ok and work smoothly as like new ipone justlike i bought it at first time. I can't restore it. So Please help me to solv this proble.

    See Here  > without the Backup  >  http://support.apple.com/kb/HT4137

  • How do I reorder songs in a playlist in the new itunes??? I can no longer just click and drag. When I click, it doesn't move!!!! Need help ASAP- trying to prepare for an aerobics class and need songs in a specific order!

    How do I reorder songs in a playlist in the new itunes??? I can no longer just click and drag. When I click, it doesn't move!!!! Need help ASAP- trying to prepare for an aerobics class and need songs in a specific order!

    Vera,
    Use View > View Options, and set 'Sort By" to "Manual Order."
    Then you will be able to drag-n-drop songs up and down the list.

  • Itunes is not recognizing my ipod.  there is no sync under file.  I need to download the music just purchased from itunes.

    itunes is not recognizing my ipod.  there is no sync under file.  I need to download the music just purchased from itunes.
    can anyone help?

    Do you see your iPod under Devices on the left side of the iTunes window in the source list when it's connect to your Mac?
    BTW...  you sync iTunes media from the tabs in the iTunes menu, not from the File menu unless you are transferring iTunes purchases from the iPod to your Mac.
    Might need to zoom to see this graphic. I have "Music" selected as an example.

  • Heading to Sri Lanka - do I need a voltage converter or just the plug adapter for my Ipad?

    To recharge my IPAD do I need a voltage converter or just an outlet plug adapter?  The print on the plug that came with the IPAD is so small I can't read it!

    Just the plug adapter, as the power brick itself can go from 100-240 VAC, 50-60Hz. I'd take a spare charger and cable, just in case.

  • Hello, i really need help. I had just updated my iphone 3gs to 6.0.1, and after I updated, it won't activate.

    Hello, i really need help. I had just updated my iphone 3gs to i.o.s. 6.0.1, and after I updated, it won't activate.I tried it in itunes and it always says " We cannot activate your iphone at this time..." and when I activate using Wi-Fi, it says, "Your iPhone cannot be activated because the activation server is temporarily unavailable." I could swear that my Wi-Fi is fine, and my Itunes is on the latest version.  Is this a bad thing or does this normally occurs? Can I still fix this ? I'm so desperate to use my iphone cause I use it everyday for personal purposes. I sure would appreciate any tip or help . PLSSSS ! Thank you for that wonderful being that can help.

    Do not take it to a third party repair shop - downgrading causes problems and voids your warranty.
    I had to unlock it so that i could really use it as a phone.
    And that is the root of the problem. Unless you had your carrier unlock it, it was hacked and cannot be legitimately activated. Even if you don't care about warranty or problems, downgrading simply will not help an activation issue.

  • Yesterday I ran Disk Utility and came up with hundreds of permissions that needed repair.  I hit the "repair permissions" button and waited until it said they were repaired, but just for fun I hit the v

    Yesterday I ran Disk Utility and came up with hundreds of permissions that needed repair.  I hit the "repair permissions" button and waited until it said they were repaired, but just for fun I hit the "verify permissions" button again, and they all came back!  I did this several more times and every time I would hit "verify permissions" I would get the same list.  What's up?  I've always suspected diagnostic programs, but this is Apple's own!

    Ignore them. They aren't errors. You will keep seeing the same ones. As long as you get the message "Permissions repair complete," you're OK.
    http://support.apple.com/kb/TS1448?viewlocale=en_US

  • Need help selecting the right MBP for me, just bought a pc with Windows 8 and I already regret it..

    Ok, so I'm an engineering student and I am in need of a good laptop to run programming and design type software. I have an older iMac which I love but I need the portability of a laptop for school. I was thinking I would be fine with a pc since most of the software I would be using for school is windows based. So last night, after shopping around for quite a bit, I decided to go with a Sony Vaio E series laptop with Windows 8, 8gb ram, i7 processor, dedicated graphics card, 1tb hard drive, and touch screen. It was the best performance laptop (on paper) Best Buy had in the store for just under $1000. I would have loved to get an upper end MBP but they are over twice the price as the Sony.. So I get it home with the Vaio and it feels laggy and glitchy, it takes 2 seconds for the window to pop up after 'right clicking', I can see lines in the screen, the resolution seems far from HD when on the normal looking windows side (as opposed to the tablet look, forgive my poor terminology) and the web browser, and the touch pad seems to be hit or miss in that it doesn't always register the touch pad commands. I checked all of the visual and performance settings, made the resolution as high as possible, changed some of the settings to the high performance settings, made sure all of my drivers were updated, and the only effect was a very loud fan that runs constantly.
    So in short, I am going to take this back and start looking at the macbook pros. Here's my dilemna, I don't know which specs I will definitely need in a Macbook Pro. I need to be able to run windows on it either in parallel or as a partition for my programs necessary for school. Can the MBP run windows smoothly enough to run 3D design types of programs? If so, which one should I get? I love the size of the 13" MBP but it only has a dual core processor, instead of the quad core like the 15" MBP, I'm not sure if I definitely need the quad over the dual core. I would love a solid state MBP but they are out of my price range and not enough space if I end up partitioning it.
    Sorry for the book, but school starts Monday and I need some direction to find out which one I need to get fairly quickly. Any help would be greatly appreciated.

    Take a look at this MBP, a refurbished unit.  Don't let the late 2011 release date put you off.  For about  $500 less than an equivalent 'new' one with similar specifications you get a quad core CPU and excellent graphics.  As Steve359 mentioned, this can be upgraded if the need arises and has the same warranty as a 'new' one
    I would not be surprised that these may actually be 'new' MBPs due to the length of time that they have been replaced by the current generation.  I purchased a 17" model about 5 weeks ago, and a serial number check suggests that it is 9 weeks old.
    http://store.apple.com/us/product/G0NM5LL/A
    Ciao.

  • I updated to ios 5.1.1 and added icloud services. the problem is now whenever i connect my iphone to my PC, itunes does not recognize my phone. i need it to but it just does not connect..

    i updated to ios 5.1.1 and added icloud services. the problem is now whenever i connect my iphone to my PC, itunes does not recognize my phone. i need it to but it just does not connect..

    Try the standard fixes to rule out a software problem:
    - Reset. Nothing is lost
    Reset iPod touch: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Restore from backup
    - Restore to factory defaults/new iPod.
    If you still have the problem that points to a hardware problem. Yu can make an appointment at the the Genius Bar of an Apple store or try:
    fix for Home button

  • Hi, can someone help me, I did my first page in Muse, and I did just for computer, I need to do for tablet and phone, I have to do?  thx

    Hi, can someone help me, I did my first page in Muse, and I did just for computer, I need to do for tablet and phone, I have to do?  thx
    Esto puede ser en español? por favor

    Hello,
    Please refer to the links below, you will find them very useful.
    Adobe Muse Help | Creating a website for Mobile devices
    How to create a mobile website with Adobe Muse | Adobe Muse CC tutorials
    Video Tutorials:
    Design for mobile first | Adobe Muse CC tutorials
    Mobile best practices | Adobe Muse CC tutorials
    Plan your mobile site | Adobe Muse CC tutorials
    Preview your mobile site | Adobe Muse CC tutorials
    How to create a mobile website with Adobe Muse | Adobe Muse CC tutorials
    Regards
    Vivek

Maybe you are looking for

  • Can not cancel proforma invoice

    dear all, we are working on project scenario. we make delivery through projects (t code CNS0) we have create two deliveries and try to combine in one proforma invoice. but system created two separate documents. error we found that foreign trade data

  • Read and write at the same time. Or: Read while the file is being written.

    Hello I'm a student working on a live streaming project. The video i get should be streamed live, so i have to read the file from disk while it is written. When I try to do this I get an access denied or permission denied (i can provide the detailed

  • Oversaturated prints not matching Pantone swatch

    Head is melting with this HP lazerjet 2550L. Nothing prints as it should or matches Pantone swatches. All my prints are way too intense in colour but the odd thing is that my monitor matches exactly the pantones in the swatch booklet (which is new, n

  • How do I safely synchronize my BlackBerry Contacts with my Microsoft outlook Contacts?

    I have lots of contacts on my BlackBerry, transferred from previous phones I've owned. This was the most difficult transfer I ever did as it seems BlackBerry is different to regular mobile phones. Now I would like to store all this information in Mic

  • Safari extremely slow after 10.5.4 upgrade

    After recently updating to 10.5.4 Safari has become a problem. I use Airport Extreme connected to an ADSL router and this has always worked brilliantly, but since the latest update Safari is not downloading internet pages with the same reliability or