Home  >  Q&A  >  body text

java - 用了ThreadLocal,Connection对象是不是只有一个?

用了ThreadLocal,connection对象是不是只有一个?

每个线程的threadLocals中保存的都是connection对象的副本?

这样的理解是正确的么?

connection对象可以共用么?

高洛峰高洛峰2717 days ago366

reply all(2)I'll reply

  • 巴扎黑

    巴扎黑2017-04-18 09:53:53

    With ThreadLocal connection, it is not the same.
    Every thread keeps a copy of itself.
    Connection objects are generally used by a single thread. No concurrent calls across threads.

    reply
    0
  • PHP中文网

    PHP中文网2017-04-18 09:53:53

    "Each thread keeps a copy of itself", why not use a connection pool to manage it?

    reply
    0
  • Cancelreply