jackson的ObjectMapper是否线程安全

hxywdzk 2014-08-29 07:48:43
jackson中的ObjectMapper是否线程安全,能否单例生成全局使用
请大神帮忙解释下,有测试用例就更好了
...全文
3243 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
捏造的信仰 2014-09-02
  • 打赏
  • 举报
回复
官方网站有答案,参考 http://wiki.fasterxml.com/JacksonFAQ Is ObjectMapper thread-safe? Short answer: yes Long answer: yes, as long as you always configure instance before use, and do not call configure methods during operation (or synchronize such calls appropriately). Usually it is better to construct separate mapper instance if configurations differ in any case. Further: it is beneficial to use just one instance (or small number of instances) for data binding; many optimizations for reuse (of symbol tables, some buffers) depend on ObjectMapper instances being reused.

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧