Spring的TransactionTemplate和SimpleJdbcTemplate是线程安全的吗? [英] Is the spring TransactionTemplate and SimpleJdbcTemplate thread-safe?
本文介绍了Spring的TransactionTemplate和SimpleJdbcTemplate是线程安全的吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我目前正在处理代码,其中有一个单例,它被许多线程使用,并且没有状态,除了两个字段用于TransactionTemplate和SimpleJdbcTemplate,它们在单例函数中用于访问数据库。
I am currently dealing with code where there is a singleton which is used by many threads and has no state except two fields for a TransactionTemplate and a SimpleJdbcTemplate which are used in the functions of the singleton to access the database.
这是安全还是我需要创建一个新模板?
Is this safe or should I create a new Template, whenever I need one?
推荐答案
SimpleJdbcTemplate只包装了一个JdbcTemplate,所以它是线程安全的,就像 TransactionTemplate 。
The SimpleJdbcTemplate just wraps a JdbcTemplate, so it's thread-safe, as is the TransactionTemplate.
这篇关于Spring的TransactionTemplate和SimpleJdbcTemplate是线程安全的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文