Java 7 Calendar.getInstance,TimeZone.getTimeZone得到同步和缓慢,任何解决方法? [英] Java 7 Calendar.getInstance, TimeZone.getTimeZone got synchronized and slow, any work arounds?
问题描述
将我的运行时升级到Java 7之后,我看到了令人难以置信的缓慢......我的程序将所有时间花在 SimpleDateFormat
构造函数上。正如这篇文章中所描述的那样: http://coffeedriven.org/?p=83 TimeZone
代码现在检查静态同步
方法中是否存在应用程序上下文 getDefaultInAppContext ()
。
After upgrading my runtime to Java 7 I see incredible slowness... and my program is spending all of its time in the SimpleDateFormat
constructor. As described in a great post here: http://coffeedriven.org/?p=83 the TimeZone
code is now checking for the presence of an application context in the static synchronized
method getDefaultInAppContext()
.
我的问题是它是 Spring Batch 文件阅读器代码,为它读取的每一行创建一个新的SimpleDateFormat
对象!
The problem for me is that it's Spring Batch file reader code that is creating a new SimpleDateFormat
object for each line that it reads!
任何人都可以解决这个问题吗?
Anyone got a work around for this?
推荐答案
我们通过改变来解决这个问题到Spring Batch本身。目前,更改是在本地副本中,但我已经输入了Jira问题,并希望将我们的修复程序返回给Spring Batch本身。
We solved this by making a change to Spring Batch itself. For now the change is in a local copy but I've entered a Jira issue and hope to contribute our fix back to Spring Batch itself.
更改本身就是要更改从成员变量到注入的变量使用SimpleDateFormat(无论如何看起来更像Spring)。这让我们可以控制它的生命周期。
The change itself is to change the use of SimpleDateFormat from a member variable to an injected one (which seems more Spring-like anyway). This lets us control its lifecycle.
这篇关于Java 7 Calendar.getInstance,TimeZone.getTimeZone得到同步和缓慢,任何解决方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!