如何在多线程应用程序中使用语言环境以提高性能 [英] How Locale could be used in multithreaded application to improve performance

查看:52
本文介绍了如何在多线程应用程序中使用语言环境以提高性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我有一个同时被多个线程调用的方法.每个线程在运行时都会多次调用此方法.

In my application I have a method which is called by multiple threads simultaneously. Each thread calls this method many times while running.

private Locale trLoc = new Locale("tr", "TR");

public double calculate(String arg1){
    arg1 = arg1.toUpperCase(trLoc);
...
}

此方法进行String.toUpperString(Locale)调用,由于Locale类中使用HashTable导致瓶颈.每个线程在toUpperCase方法运行时等待另一个线程.这种情况使我的应用程序速度降低了三倍.

This method makes a String.toUpperString(Locale) call which causes a bottleneck because of the HashTable usage within the Locale class. Each thread waits other one while toUpperCase method operates. This situation slows down my application up to three times.

使用语言环境时是否缺少某些东西,或者出于相同的目的必须使用其他类?

Is there something I'm missing with the usage of the Locale or I must use another class for the same purpose?

提前谢谢.

推荐答案

短时间探索之后,JDK似乎无济于事.我建议获取java.lang.ConditionalSpecialCasing类,将其复制并解决Hashtable的问题.您可以将Hashtable替换为HashMap.我看不出在这里使用Hashtable的任何理由.

After short exploring it looks like JDK can't help you. I suggest get java.lang.ConditionalSpecialCasing class, copy it and fix problem with Hashtable. You may replace Hashtable with HashMap. I do not see any reason for using Hashtable here.

这篇关于如何在多线程应用程序中使用语言环境以提高性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆