当前项目的connection都是放在ThreadLocal里面的。由于我的某个功能操作有部分打算异步处理,new Thread(()->{//.......}).start() 这样就导致无法使用dao了。因为dao需要的connection在ThreadLocal中。
高洛峰2017-04-18 09:53:54
The connection must be released after each use. The next time you connect, just go to threadlocal to get the value. I don’t understand what you mean.
怪我咯2017-04-18 09:53:54
When creating a new Thread, take the connection out of ThreadLocal and pass it in
阿神2017-04-18 09:53:54
Just write the execution part independently, so you don’t need to pass the dao to Thread
ringa_lee2017-04-18 09:53:54
If this asynchronous operation is non-transaction related to the previous logic. That is to say, they are not in the same transaction.
Then you can use a new link.
If there is a transaction, this old link must be used. This connection object can only be passed to the thread.