Why is NumberFormat.cachedLocaleData still a Hashtable?

Looking at JDK 6, NumberFormat.getInstance(Locale) is a bottleneck at high concurrency, because it hits a synchronized block calling cacheLocaleData.get(locale). The latter is a Hashtable - shouldn't it be a ConcurrentMap by now?
Not sure what LocaleServiceProviderPool is but it appears to not have providers so the executions does hit cacheLocalData.get() on every invocation. The problem is many web frameworks rely on MessageFormat or NumberFormat.getInstance() to convert presentation data String<>Int and so this method may get called 100s of times per page render (imagine rendering a table of formatted numbers).
Is the workaround to 'new' DecimalFormat directly and put it on a ThreadLocal (to avoid calling NumberFormat.getInstance())?
private static final Hashtable cachedLocaleData = new Hashtable(3);
    private static NumberFormat getInstance(Locale desiredLocale,
                                           int choice) {
        // Check whether a provider can provide an implementation that's closer
        // to the requested locale than what the Java runtime itself can provide.
        LocaleServiceProviderPool pool =
            LocaleServiceProviderPool.getPool(NumberFormatProvider.class);
        if (pool.hasProviders()) {
            NumberFormat providersInstance = pool.getLocalizedObject(
                                    NumberFormatGetter.INSTANCE,
                                    desiredLocale,
                                    choice);
            if (providersInstance != null) {
                return providersInstance;
        /* try the cache first */
        String[] numberPatterns = (String[])cachedLocaleData.get(desiredLocale);
        if (numberPatterns == null) { /* cache miss */
            ResourceBundle resource = LocaleData.getNumberFormatData(desiredLocale);
            numberPatterns = resource.getStringArray("NumberPatterns");
            /* update cache */
            cachedLocaleData.put(desiredLocale, numberPatterns);
        }

nikita_bludevil wrote:
Is the workaround to 'new' DecimalFormat directly and put it on a ThreadLocal (to avoid calling NumberFormat.getInstance())?I would use a ThreadLocal

Similar Messages

  • Why old message are still in the mail queue

    Hi all,
    I would like to know why old messages are still in the ims-ms queue and not deliver to recipient?
    qm.maint> summ
    Messages
    Channel Queued Size (Kb) Oldest
    tcp_local 0 0.00
    tcp_intranet 0 0.00
    tcp_auth 0 0.00
    reprocess 0 0.00
    process 0 0.00
    pmxchannel 176 50912.86 4 Dec, 10:06:04
    native 0 0.00
    ims-ms      93    83309.79    3 Dec, 11:25:04
    defragment 0 0.00
    Totals 269 134222.65
    I went to message location and saw the "ZZf0M2s0h2Xp1.HELD" message in /opt/SUNWmsgsr/queue/ims-ms/000
    what does this mean "HELD" messages?
    Anyone can explain in this? thanks.

    Yap wrote:
    I would like to know why old messages are still in the ims-ms queue and not deliver to recipient? As always, what version of messaging server are you running (./imsimta version)?
    qm.maint> summ
    Messages
    Channel Queued Size (Kb) Oldest
    ims-ms      93    83309.79    3 Dec, 11:25:04
    If you run the following command, are the emails all destined to the same user?
    ./imsimta qm
    dir -env ims-msAlso have you experience a core dump/process crash recently (do you have coreadm enabled)?
    I went to message location and saw the "ZZf0M2s0h2Xp1.HELD" message in /opt/SUNWmsgsr/queue/ims-ms/000
    what does this mean "HELD" messages? Refer here:
    http://docs.sun.com/app/docs/doc/819-4428/bgbhg?a=view
    Regards,
    Shane.
    Anyone can explain in this? thanks.

  • I did download Lion and everything is fine, but why in app store still stated DOWNLOAD and not INSTALLED, I already did 3 times and it still in DOWNLOAD label

    I did download Lion and everything is fine, but why in app store still stated DOWNLOAD and not INSTALLED, I already did 3 times and it still in DOWNLOAD label

    My guess is they changed that to Download for all the people who wanted to or needed to download it again. It's kind of a subset of Installed, now. I don't think it is a great solution, but that is what it is.

  • Why is my ipad still using battery power when switched off & locked away with no one using it?

    Why is my IPad still discharging battery when switched off and locked away - with no one using it?  Charged it to 100% on holiday and locked in safe.  2 days later it was at 76%!

    How is it "switched off"? Are you pressing the button on the top so the screen goes black? If so, that isn't shut off, but put to sleep. I will still be doing things in the background and using battery power.
    To shut it fully off, press and hold the button on top, you will get a notification on the screen that says "Slide to power off". Slide the button and it will turn completly off.
    If this is how you switched it off, let us know and we will see what else we can figure out.

  • HT1222 Why my iphone 5 still cannot install this update? I've clicked the download and install button but it do nothing, im using wifi and the baterry is 100% but still, it do nothing when i've clicked! Help!

    Why my iphone 5 still cannot install this update? I've clicked the download and install button but it do nothing, im using wifi and the baterry is 100% but still, it do nothing when i've clicked! Help!

    Reset the phone (no data loss): Press both the home and power buttons for at least 10 seconds, releasing when the Apple logo appears.  After the phone restarts, try updating again.

  • Why the new iPad still has no Flash

    I wonder why the new iPad still has no flash. I love to take photos with my iPhones and iPads, sometimes a flash could be handy when it's dark.
    I know it could be another nightmare for the Apple case makers.

    Apple has never said why, and rarely does explain decisions like that... my guess is that it would have taken space and power away from something else, it's a pretty tightly-packed product. :-)

  • I'm using iPhone 4S, why my weekdays alarm still not working?

    I'm using iPhone 4S, why my weekdays alarm still not working?
    By the way, single alarm is working.

    wifi appears to be OFF and ON on my device !.
    but when i used to turn it ON , it is not showing anything.
    just showing as 'searching for devices'.

  • Why the links are still opened in new windows?

    Why the links are still opened in new windows even I selected the option to open in tabs?
    This is one of the web I am reading (sorry that it is in simplified Chinese), I have no problems reading it in tabs in Firefox:
    http://www.sodu.com.cn/mulu_30498.html

    Hi,
    How are you trying to open the windows? Safari does not default to opening new windows in tabs. It can open +external application+ links (e.g. from your email program, RSS viewer, etc) in a new tab, but not links from an existing website.
    To open links in a new tab, you'll need to hold the ctrl key and click the link, or use the middle-mouse button if your mouse has one (or right-click on the link and choose to open it in a new tab).

  • Why are animated GIFs still broken?

    https://discussions.apple.com/thread/1229922 <-- this
    'nuff said, this has been a problem ever since Preview lost its ability to animate GIFs. It may be a WebKit problem (i.e. yeah, Apple, just go ahead and let yourself off the hook...right), but regardless, how come it has not been addressed sooner? Safari chokes after about 4 frames of animation; if the GIF loops, it starts over fresh, but it chokes again.
    I am using 10.5.8, but I am aware this is still a problem for all 10.6 OSes and iOSes. I don't know about Safari for Windows; not relevant at the moment.
    Why is this still a problem after three-and-a-half years of Safari development have passed?

    Well, here are the issues I have run into.
    1) Gifs load half way and then animate on the base but not on the top.
    2) Gifs animate waaaaaaay too fast.
    I have found no solution for the 1st issue, and it does not always occur.
    As for the second one it has to do with browsers all reading the "0 delay" setting of the animation at uniquee speeds. Most round it to 10/100th of a sec, while Safari loads it at 3/100th resulting in a faster images, but a non-standard speed. Which ***** since I am running animations that follow using a set time out only to have safari throw everything off. I think one other browser runs at something like 6/100ths so Safari is not the only one. Faster could be nice if they all got on the same page, but as they are it is pointless. Pretty much meaning if you want an animated gif you have to avoid the "0 delay setting at all costs, and pretty much anything under 1/10th because it will not display the same in many browsers. It could be this fast speed in Safari that is causing the loading and instability issues with sime.

  • Why is vertical centering still such a challenge?

    Is it really still this tricky to code DW to allow easy vertical centering? Just wondering. Tools for web design have been around long enough, and yet, simply vertically centering an image remains... elusive. Sure - if you know exactly how to do it, or remember it, or figure it out.... sometimes I can get it to work with relative ease; other times, not so much.
    Really, though - no vertical center button anywhere?  (I may have missed it.)
    Now, I admit, I have some homework to do; in the mean time, though, is there any guide someone can recommend?
    I'd like to both center divs vertically as well as center their content vertically, and not necessarily both at the same time... preferably using css.
    thanks,
    Andrew

    as to why this is this case is presumably because as the width of an element shrinks, margins-top and position-top and height are contingent on that allowed width.  But margin-top and margin-bottom by default are set to auto. This may make it seem like vertical alignments should occur naturally, but it does not. This is because behind the scenes auto is converted to 0. Meaning that Height auto is automatically set to 100% of its containers height leaving no room for margin-top or margin-bottom.  Vertical formatting of block level normal flow elements, relies on a calculation much like horizontal formatting.  margin-top+border-top+padding-top+height+padding-bottom+border-bottom+margin-bottom must equal its parenting elements height.    However if you use absolutely positioned elements, then if all three of 'top', 'height', and 'bottom' are not auto: If both 'margin-top' and 'margin-bottom' are 'auto', solve for  top+ margin-top+border-top+padding-top+height+padding-bottom+border-bottom+margin-bottom +bottom must equal its parenting elements height. Therefore, margin-top and margin-bottom will be equal values thus vertically centering the element.

  • Why does the last still always go first?!

    Funny thing keeps happening.  I will have a load of still photos I want to add to eg Video 2 above a gray color matte on video 1.   Using mouse + Shift in a standard way, with everything set to Sort by File Name Ascending, I drag the lot.  Invariably the last picture for some weird reason always puts itself at #1, so that I have to move it manually to the end.
    Hey, why?!  LOL   A minor irritation!
    Brian

    Brian
    You are using Premiere Elements 11, Windows. Is that correct?
    I just took an double check with my Premiere Elements 11 and Project Assets/Sort By/
    a. File Name (Ascending)
    and
    b. Duration (Ascending)
    I had two files,
    Wildlife.wmv, 30 seconds
    and
    Windows Movie Maker Sample File.wmv, 12 seconds
    Project Assets
    List View
    Sort By File Name (Ascending)
    In Project Assets, Wildlife.wmv on top and Windows Movie Maker Sample File.wmv bottom
    When selected there together and dragged to the Expert workspace Timeline together
    Wildlife.wmv first, Windows Movie Maker Sample File.wmv, second
    Project Assets
    List View
    Sort By Duration (Ascending)
    In Project Assets, Windows Movie Maker Sample File.wmv top and Wildlife.wmv bottom
    When selected there together and dragged to the Expert workspace Timeline together
    Windows Movie Maker Sample File.wmv first, and Wildlife.wmv, second
    I repeated the above with Project Assets in the Grid View and go the same trend in results.
    So, I am not clear why you are getting what you described. Could you give us a sampling of the file names involved in
    your observations and the duration of each of the files?
    If you are in the List View, are you clicking on the "name" tab above the list of imported files. That will reverse the ordering of
    the files in Project Assets List View. But, from what you describe, I do not think that is it.
    ATR

  • TS2446 Why is my account still disabled even after resetting my password?

    I have not been on my account for awhile but when I did I had forgotten my ID and password info.  When I recovered it from a note I found, I reset the password but was still unable to buy music and dowload.  When I went to dowload a song, it said my account was disable and to contact support.
    Kathy Kimsey

    If you haven't already done so then you can contact iTunes Support via this link and ask them why the message is appearing (we are fellow users here on these forums, we won't know why) : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page, then Purchases, Billing & Redemption

  • Why use DVD install still need to type serial number

    I download iwork 09 trial version and before expire, I order a DVD version.
    after finish from DVD, still ask me to enter the serial number, why??

    Hi GovBob,
    You do not need to do this with LabVIEW 2009 and TestStand 4.2.1. If you navigate to this location: C:\Documents and
    Settings\All Users\Documents\National Instruments\TestStand
    4.2.1\AdapterSupport\LabVIEW you will see that there is  Default Values 90.llb folder already.
    Cheers,
    Kelly R.
    Applications Engineer
    National Instruments

  • Why is i pod still not syncing unknown error occured 13019

    why is my i pod still not synced unkown error occured 13019???

    No need to shout!  Not good manners.  Typing in caps is considered shouting. 
    Just click on the link I posted.

  • Why is -100% saturation still yielding faint colors?

    When working in "develop" - "basic", using adjustment brush at -100% saturation is still leaving my image with faint colors..... why would this happen and what am I missing to make this process work correctly?  Thanks..

    Are flow and density set to 100?

Maybe you are looking for