How to improve performance of SimpleDateFormat wrapped in ThreadLocal?

前端 未结 4 1972
梦如初夏
梦如初夏 2020-12-25 12:54

This is on Java 7 (51) on RHEL with 24 cores We are noticing a rise in average response times of a java SimpleDateFormat wrapped in thread local as we increase the thread po

4条回答
  •  梦毁少年i
    2020-12-25 13:43

    Creating an instance of SimpleDateFormat is very expensive (this article shows some profiling/benchmarking). If this is true, compared with the parsing of the dates into strings, then it follows that as you increase the number of threads (and therefore the number of SimpleDateFormat instances as they are threadlocals) your average time is going to increase.

提交回复
热议问题