{"id":10007054,"date":"2023-01-09T18:13:16","date_gmt":"2023-01-09T10:13:16","guid":{"rendered":"https:\/\/ityet.com\/?p=10007054"},"modified":"2023-01-09T18:13:16","modified_gmt":"2023-01-09T10:13:16","slug":"threadlocal%e6%ba%90%e7%a0%81%e8%a7%a3%e6%9e%90%e5%8f%8a%e5%ae%9e%e6%88%98%e5%ba%94%e7%94%a8","status":"publish","type":"post","link":"https:\/\/itmax.cn\/?p=10007054","title":{"rendered":"ThreadLocal\u6e90\u7801\u89e3\u6790\u53ca\u5b9e\u6218\u5e94\u7528"},"content":{"rendered":"<h5>\u4f5c\u8005\uff1a\u4eac\u4e1c\u7269\u6d41 \u95eb\u9e4f\u52c3<\/h5>\n<h3>1 \u4ec0\u4e48\u662fThreadLocal\uff1f<\/h3>\n<p>ThreadLocal\u662f\u4e00\u4e2a\u5173\u4e8e\u521b\u5efa\u7ebf\u7a0b\u5c40\u90e8\u53d8\u91cf\u7684\u7c7b\u3002  <br \/>\u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u521b\u5efa\u7684\u53d8\u91cf\u662f\u53ef\u4ee5\u88ab\u4efb\u4f55\u4e00\u4e2a\u7ebf\u7a0b\u8bbf\u95ee\u5e76\u4fee\u6539\u7684\u3002\u800c\u4f7f\u7528ThreadLocal\u521b\u5efa\u7684\u53d8\u91cf\u53ea\u80fd\u88ab\u5f53\u524d\u7ebf\u7a0b\u8bbf\u95ee\uff0c\u5176\u4ed6\u7ebf\u7a0b\u5219\u65e0\u6cd5\u8bbf\u95ee\u548c\u4fee\u6539\u3002ThreadLocal\u5728\u8bbe\u8ba1\u4e4b\u521d\u5c31\u662f\u4e3a\u89e3\u51b3\u5e76\u53d1\u95ee\u9898\u800c\u63d0\u4f9b\u4e00\u79cd\u65b9\u6848\uff0c\u6bcf\u4e2a\u7ebf\u7a0b\u7ef4\u62a4\u4e00\u4efd\u81ea\u5df1\u7684\u6570\u636e\uff0c\u8fbe\u5230\u7ebf\u7a0b\u9694\u79bb\u7684\u6548\u679c\u3002<\/p>\n<h4>2 \u6709\u4ec0\u4e48\u4f5c\u7528\uff1f<\/h4>\n<h4>2.1 set once\uff0cget everywhere<\/h4>\n<p>\u5728\u73b0\u5728\u7684\u7cfb\u7edf\u8bbe\u8ba1\u4e2d\uff0c\u524d\u540e\u7aef\u5206\u79bb\u5df2\u57fa\u672c\u6210\u4e3a\u5e38\u6001\uff0c\u5206\u79bb\u4e4b\u540e\u5982\u4f55\u83b7\u53d6\u7528\u6237\u4fe1\u606f\u5c31\u6210\u4e86\u4e00\u4ef6\u9ebb\u70e6\u4e8b\uff0c\u901a\u5e38\u5728\u7528\u6237\u767b\u5f55\u540e\uff0c \u7528\u6237\u4fe1\u606f\u4f1a\u4fdd\u5b58\u5728Session\u6216\u8005Token\u4e2d\u3002\u8fd9\u4e2a\u65f6\u5019\uff0c\u6211\u4eec\u5982\u679c\u4f7f\u7528\u5e38\u89c4\u7684\u624b\u6bb5\u53bb\u83b7\u53d6\u7528\u6237\u4fe1\u606f\u4f1a\u5f88\u8d39\u52b2\uff0c\u62ffSession\u6765\u8bf4\uff0c\u6211\u4eec\u8981\u5728\u63a5\u53e3\u53c2\u6570\u4e2d\u52a0\u4e0aHttpServletRequest\u5bf9\u8c61\uff0c\u7136\u540e\u8c03\u7528 getSession\u65b9\u6cd5\uff0c\u4e14\u6bcf\u4e00\u4e2a\u9700\u8981\u7528\u6237\u4fe1\u606f\u7684\u63a5\u53e3\u90fd\u8981\u52a0\u4e0a\u8fd9\u4e2a\u53c2\u6570\uff0c\u624d\u80fd\u83b7\u53d6Session\uff0c\u8fd9\u6837\u5b9e\u73b0\u5c31\u5f88\u9ebb\u70e6\u4e86\u3002<\/p>\n<p>\u5728\u5b9e\u9645\u7684\u7cfb\u7edf\u8bbe\u8ba1\u4e2d\uff0c\u6211\u4eec\u80af\u5b9a\u4e0d\u4f1a\u91c7\u7528\u4e0a\u9762\u6240\u8bf4\u7684\u8fd9\u79cd\u65b9\u5f0f\uff0c\u800c\u662f\u4f7f\u7528ThreadLocal\uff0c\u6211\u4eec\u4f1a\u9009\u62e9\u5728\u62e6\u622a\u5668\u7684\u4e1a\u52a1\u4e2d\uff0c \u83b7\u53d6\u5230\u4fdd\u5b58\u7684\u7528\u6237\u4fe1\u606f\uff0c\u7136\u540e\u5b58\u5165ThreadLocal\uff0c\u90a3\u4e48\u5f53\u524d\u7ebf\u7a0b\u5728\u4efb\u4f55\u5730\u65b9\u5982\u679c\u9700\u8981\u62ff\u5230\u7528\u6237\u4fe1\u606f\u90fd\u53ef\u4ee5\u4f7f\u7528ThreadLocal\u7684get()\u65b9\u6cd5 (\u5f02\u6b65\u7a0b\u5e8f\u4e2dThreadLocal\u662f\u4e0d\u53ef\u9760\u7684)<\/p>\n<h4>2.2 \u7ebf\u7a0b\u5b89\u5168\uff0c\u7a7a\u95f4\u6362\u65f6\u95f4<\/h4>\n<p>\u5728Spring\u7684Web\u9879\u76ee\u4e2d\uff0c\u6211\u4eec\u901a\u5e38\u4f1a\u5c06\u4e1a\u52a1\u5206\u4e3aController\u5c42\uff0cService\u5c42\uff0cDao\u5c42\uff0c \u6211\u4eec\u90fd\u77e5\u9053<a href=\"https:\/\/link.segmentfault.com\/?enc=iqgZAklFJrjOKkT0uIBmMA%3D%3D.suMGgfuGJQVdWOa92%2FB8pzeT51Ucyn4p9D9N%2FDet3zk%3D\" rel=\"nofollow\" title=\"@Autowired\">@Autowired<\/a>\u6ce8\u89e3\u9ed8\u8ba4\u4f7f\u7528\u5355\u4f8b\u6a21\u5f0f\uff0c\u90a3\u4e48\u4e0d\u540c\u8bf7\u6c42\u7ebf\u7a0b\u8fdb\u6765\u4e4b\u540e\uff0c\u7531\u4e8eDao\u5c42\u4f7f\u7528\u5355\u4f8b\uff0c\u90a3\u4e48\u8d1f\u8d23\u6570\u636e\u5e93\u8fde\u63a5\u7684Connection\u4e5f\u53ea\u6709\u4e00\u4e2a\uff0c \u5982\u679c\u6bcf\u4e2a\u8bf7\u6c42\u7ebf\u7a0b\u90fd\u53bb\u8fde\u63a5\u6570\u636e\u5e93\uff0c\u90a3\u4e48\u5c31\u4f1a\u9020\u6210\u7ebf\u7a0b\u4e0d\u5b89\u5168\u7684\u95ee\u9898\uff0cSpring\u662f\u5982\u4f55\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\u7684\u5462\uff1f<\/p>\n<p>\u5728Spring\u9879\u76ee\u4e2dDao\u5c42\u4e2d\u88c5\u914d\u7684Connection\u80af\u5b9a\u662f\u7ebf\u7a0b\u5b89\u5168\u7684\uff0c\u5176\u89e3\u51b3\u65b9\u6848\u5c31\u662f\u91c7\u7528ThreadLocal\u65b9\u6cd5\uff0c\u5f53\u6bcf\u4e2a\u8bf7\u6c42\u7ebf\u7a0b\u4f7f\u7528Connection\u7684\u65f6\u5019\uff0c \u90fd\u4f1a\u4eceThreadLocal\u83b7\u53d6\u4e00\u6b21\uff0c\u5982\u679c\u4e3anull\uff0c\u8bf4\u660e\u6ca1\u6709\u8fdb\u884c\u8fc7\u6570\u636e\u5e93\u8fde\u63a5\uff0c\u8fde\u63a5\u540e\u5b58\u5165ThreadLocal\u4e2d\uff0c\u5982\u6b64\u4e00\u6765\uff0c\u6bcf\u4e00\u4e2a\u8bf7\u6c42\u7ebf\u7a0b\u90fd\u4fdd\u5b58\u6709\u4e00\u4efd \u81ea\u5df1\u7684Connection\u3002\u4e8e\u662f\u4fbf\u89e3\u51b3\u4e86\u7ebf\u7a0b\u5b89\u5168\u95ee\u9898<\/p>\n<h3>3 ThreadLocal\u5b9e\u6218\u5e94\u7528<\/h3>\n<h4>3.1 ehr\u4e2d\u7684\u4f7f\u7528<\/h4>\n<p>\u5728\u767b\u5f55\u62e6\u622a\u5668\u4e2d\u5c06\u7528\u6237\u4fe1\u606f\u5199\u5165\uff0c\u540e\u7eed\u4f7f\u7528\u65f6\u65b9\u4fbf\u53d6\u503c<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000043278073\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000043278074\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<h4>3.2 \u5206\u9875\u63d2\u4ef6PageHelper\u4e2d\u7684\u5e94\u7528<\/h4>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000043278075\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000043278076\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<h4>3.3 AopContext<\/h4>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000043278077\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<h3>4 \u6e90\u7801\u89e3\u8bfb<\/h3>\n<p>\u4f60\u662f\u5426\u6709\u8fd9\u6837\u7684\u7591\u60d1?\u4e3a\u4ec0\u4e48\u53ef\u4ee5\u76f4\u63a5\u62ff\u5230\uff1f\u5bf9\u8c61\u5b58\u653e\u5728\u54ea\u91cc?\u5b58\u5728\u4ec0\u4e48\u95ee\u9898\uff1f<\/p>\n<h4>4.1 get\u65b9\u6cd5<\/h4>\n<p>\u5728 get() \u65b9\u6cd5\u4e2d\u4e5f\u4f1a\u83b7\u53d6\u5230\u5f53\u524d\u7ebf\u7a0b\u7684 ThreadLocalMap\uff0c\u5982\u679c ThreadLocalMap \u4e0d\u4e3a null\uff0c\u5219\u628a\u83b7\u53d6 key \u4e3a\u5f53\u524d ThreadLocal \u7684\u503c\uff1b\u5426\u5219\u8c03\u7528 setInitialValue() \u65b9\u6cd5\u8fd4\u56de\u521d\u59cb\u503c\uff0c\u5e76\u4fdd\u5b58\u5230\u65b0\u521b\u5efa\u7684 ThreadLocalMap \u4e2d\u3002<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000043278078\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<h4>4.2 set\u65b9\u6cd5<\/h4>\n<p>\u8c03\u7528set\u65f6\uff0c\u76f4\u63a5\u8c03\u7528set(T value) \u65b9\u6cd5\u4e2d\uff0c\u9996\u5148\u83b7\u53d6\u5f53\u524d\u7ebf\u7a0b\uff0c\u7136\u540e\u5728\u83b7\u53d6\u5230\u5f53\u524d\u7ebf\u7a0b\u7684 ThreadLocalMap\uff0c\u5982\u679c ThreadLocalMap \u4e0d\u4e3a null\uff0c\u5219\u5c06 value \u4fdd\u5b58\u5230 ThreadLocalMap \u4e2d\uff0c\u5e76\u7528\u5f53\u524d ThreadLocal \u4f5c\u4e3a key\uff1b\u5426\u5219\u521b\u5efa\u4e00\u4e2a ThreadLocalMap \u5e76\u7ed9\u5230\u5f53\u524d\u7ebf\u7a0b\uff0c\u7136\u540e\u4fdd\u5b58 value\u3002<\/p>\n<p>ThreadLocalMap \u76f8\u5f53\u4e8e\u4e00\u4e2a HashMap\uff0c\u662f\u771f\u6b63\u4fdd\u5b58\u503c\u7684\u5730\u65b9  <br \/>map\u7684set\uff0c\u5982\u679cmap\u4e3a\u7a7a\uff0c\u5219\u521b\u5efa\u4e00\u4e2a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000043278079\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000043278080\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<h4>4.3 initialValue() \u65b9\u6cd5<\/h4>\n<p>initialValue() \u662f ThreadLocal \u7684\u521d\u59cb\u503c\uff0c\u9ed8\u8ba4\u8fd4\u56de null\uff0c\u5b50\u7c7b\u53ef\u4ee5\u91cd\u5199\u6539\u65b9\u6cd5\uff0c\u7528\u4e8e\u8bbe\u7f6e ThreadLocal \u7684\u521d\u59cb\u503c\u3002<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000043278081\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<h4>4.4 remove() \u65b9\u6cd5<\/h4>\n<p>ThreadLocal \u8fd8\u6709\u4e00\u4e2a remove() \u65b9\u6cd5\uff0c\u7528\u6765\u79fb\u9664\u5f53\u524d ThreadLocal \u5bf9\u5e94\u7684\u503c\u3002\u540c\u6837\u4e5f\u662f\u540c\u8fc7\u5f53\u524d\u7ebf\u7a0b\u7684 ThreadLocalMap \u6765\u79fb\u9664\u76f8\u5e94\u7684\u503c\u3002<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000043278082\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>getMap\u62ff\u5230\u4e86\u4ec0\u4e48\uff1f  <br \/>\u5728 set\uff0cget\uff0cinitialValue \u548c remove \u65b9\u6cd5\u4e2d\u90fd\u4f1a\u83b7\u53d6\u5230\u5f53\u524d\u7ebf\u7a0b\uff0c\u7136\u540e\u901a\u8fc7\u5f53\u524d\u7ebf\u7a0b\u83b7\u53d6\u5230 ThreadLocalMap\uff0c\u5982\u679c ThreadLocalMap \u4e3a null\uff0c\u5219\u4f1a\u521b\u5efa\u4e00\u4e2a ThreadLocalMap\uff0c\u5e76\u7ed9\u5230\u5f53\u524d\u7ebf\u7a0b<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000043278083\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u6b64\u5904t\u662fThread\uff0c\u76f4\u63a5\u53ef\u4ee5\u201c\u70b9\u201d\u62ff\u5230\u8fd9\u4e2amap  <br \/>\u6bcf\u4e2aThread\u5bf9\u8c61\u5185\u90e8\u90fd\u7ef4\u62a4\u4e86\u4e00\u4e2aThreadLocalMap\u8fd9\u6837\u4e00\u4e2aThreadLocal\u7684Map\uff0c\u53ef\u4ee5\u5b58\u653e\u82e5\u5e72\u4e2aThreadLocal<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000043278084\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u5728\u4f7f\u7528 ThreadLocal \u7c7b\u578b\u53d8\u91cf\u8fdb\u884c\u76f8\u5173\u64cd\u4f5c\u65f6\uff0c\u90fd\u4f1a\u901a\u8fc7\u5f53\u524d\u7ebf\u7a0b\u83b7\u53d6\u5230 ThreadLocalMap \u6765\u5b8c\u6210\u64cd\u4f5c\u3002\u6bcf\u4e2a\u7ebf\u7a0b\u7684 ThreadLocalMap \u662f\u5c5e\u4e8e\u7ebf\u7a0b\u81ea\u5df1\u7684\uff0cThreadLocalMap \u4e2d\u7ef4\u62a4\u7684\u503c\u4e5f\u662f\u5c5e\u4e8e\u7ebf\u7a0b\u81ea\u5df1\u7684\u3002\u8fd9\u5c31\u4fdd\u8bc1\u4e86 ThreadLocal \u7c7b\u578b\u7684\u53d8\u91cf\u5728\u6bcf\u4e2a\u7ebf\u7a0b\u4e2d\u662f\u72ec\u7acb\u7684\uff0c\u5728\u591a\u7ebf\u7a0b\u73af\u5883\u4e0b\u4e0d\u4f1a\u76f8\u4e92\u5f71\u54cd\u3002<\/p>\n<h3>5 \u4f7f\u7528\u6ce8\u610f\u4e8b\u9879<\/h3>\n<p><strong>1\uff09\u6709\u53ef\u80fd\u5bfc\u81f4\u5185\u5b58\u6cc4\u6f0f\uff0c\u4f7f\u7528\u5b8c\u6bd5\u540e\uff0c\u9700\u8981remove<\/strong><\/p>\n<p>\u5728 ThreadLocalMap \u7684 set()\uff0cget() \u548c remove() \u65b9\u6cd5\u4e2d\uff0c\u90fd\u6709\u6e05\u9664\u65e0\u6548 Entry \u7684\u64cd\u4f5c\uff0c\u8fd9\u6837\u505a\u662f\u4e3a\u4e86\u964d\u4f4e\u5185\u5b58\u6cc4\u6f0f\u53d1\u751f\u7684\u53ef\u80fd\u3002  <br \/>Entry \u4e2d\u7684 key \u4f7f\u7528\u4e86\u5f31\u5f15\u7528\u7684\u65b9\u5f0f\uff0c\u8fd9\u6837\u505a\u662f\u4e3a\u4e86\u964d\u4f4e\u5185\u5b58\u6cc4\u6f0f\u53d1\u751f\u7684\u6982\u7387\uff0c\u4f46\u4e0d\u80fd\u5b8c\u5168\u907f\u514d\u5185\u5b58\u6cc4\u6f0f\u3002<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000043278085\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u5047\u8bbe Entry \u7684 key \u6ca1\u6709\u4f7f\u7528\u5f31\u5f15\u7528\u7684\u65b9\u5f0f\uff0c\u800c\u662f\u4f7f\u7528\u4e86\u5f3a\u5f15\u7528\uff1a\u7531\u4e8e ThreadLocalMap \u7684\u751f\u547d\u5468\u671f\u548c\u5f53\u524d\u7ebf\u7a0b\u4e00\u6837\u957f\uff0c\u90a3\u4e48\u5f53\u5f15\u7528 ThreadLocal \u7684\u5bf9\u8c61\u88ab\u56de\u6536\u540e\uff0c\u7531\u4e8e ThreadLocalMap \u8fd8\u6301\u6709 ThreadLocal \u548c\u5bf9\u5e94 value \u7684\u5f3a\u5f15\u7528\uff0cThreadLocal \u548c\u5bf9\u5e94\u7684 value \u662f\u4e0d\u4f1a\u88ab\u56de\u6536\u7684\uff0c\u8fd9\u5c31\u5bfc\u81f4\u4e86\u5185\u5b58\u6cc4\u6f0f\u3002\u6240\u4ee5 Entry \u4ee5\u5f31\u5f15\u7528\u7684\u65b9\u5f0f\u907f\u514d\u4e86 ThreadLocal \u6ca1\u6709\u88ab\u56de\u6536\u800c\u5bfc\u81f4\u7684\u5185\u5b58\u6cc4\u6f0f\uff0c\u4f46\u662f\u6b64\u65f6 value \u4ecd\u7136\u662f\u65e0\u6cd5\u56de\u6536\u7684\uff0c\u4f9d\u7136\u4f1a\u5bfc\u81f4\u5185\u5b58\u6cc4\u6f0f\u3002<\/p>\n<p>ThreadLocalMap \u5df2\u7ecf\u8003\u8651\u5230\u8fd9\u79cd\u60c5\u51b5\uff0c\u5e76\u4e14\u6709\u4e00\u4e9b\u9632\u62a4\u63aa\u65bd\uff1a\u5728\u8c03\u7528 ThreadLocal \u7684 get()\uff0cset() \u548c remove() \u7684\u65f6\u5019\u90fd\u4f1a\u6e05\u9664\u5f53\u524d\u7ebf\u7a0b ThreadLocalMap \u4e2d\u6240\u6709 key \u4e3a null \u7684 value\u3002\u8fd9\u6837\u53ef\u4ee5\u964d\u4f4e\u5185\u5b58\u6cc4\u6f0f\u53d1\u751f\u7684\u6982\u7387\u3002\u6240\u4ee5\u6211\u4eec\u5728\u4f7f\u7528 ThreadLocal \u7684\u65f6\u5019\uff0c\u6bcf\u6b21\u7528\u5b8c ThreadLocal \u90fd\u8c03\u7528 remove() \u65b9\u6cd5\uff0c\u6e05\u9664\u6570\u636e\uff0c\u9632\u6b62\u5185\u5b58\u6cc4\u6f0f\u3002<\/p>\n<p><strong>2\uff09\u4f7f\u7528\u7ebf\u7a0b\u6c60\u65f6\uff0c\u7236\u5b50\u7ebf\u7a0b\u4f20\u9012\u614e\u7528\uff0c\u56e0\u4e3a\u521d\u59cb\u5316\u65f6\u673a\u4e3a\u7ebf\u7a0b\u521b\u5efa\u65f6<\/strong><\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000043278086\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p><strong>3\uff09\u9488\u5bf92\u6709\u4ec0\u4e48\u65b9\u6848\u53ef\u4ee5\u89e3\u51b3\uff1f<\/strong>  <br \/>TransmittableThreadLocal  <br \/>\u6e90\u7801\u5730\u5740\uff1a\u00a0<a href=\"https:\/\/link.segmentfault.com\/?enc=jzvLumtj2HWkDf2r9IwVXg%3D%3D.xu2veZ2UsLeoPMuBX%2FI7AvpnYJJdK24%2FeyA%2BMGvsNs3PviECzGbrSI%2Bo%2B1CyORMvAIqT%2FUo62PQ0Gcx8q%2BG%2FKQ%3D%3D\" rel=\"nofollow\">https:\/\/github.com\/alibaba\/tr&#8230;<\/a>  <br \/>\u8be6\u89e3\uff1a<a href=\"https:\/\/link.segmentfault.com\/?enc=SFIZvbjCsER2C5ZVD61jrw%3D%3D.UiE2dwkHn9XlZ6aGj63Mxfkg1qPfzFiUvc30qQGknR8xHcdKlmxUkQoJD1bbyxOc\" rel=\"nofollow\">https:\/\/www.jianshu.com\/p\/e07&#8230;<\/a><\/p>\n<p><a href=\"https:\/\/segmentfault.com\/a\/1190000043278071\">https:\/\/segmentfault.com\/a\/1190000043278071<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f5c\u8005\uff1a\u4eac\u4e1c\u7269\u6d41 \u95eb\u9e4f\u52c3 1 \u4ec0\u4e48\u662fThreadLocal\uff1f ThreadLocal\u662f\u4e00\u4e2a\u5173\u4e8e\u521b\u5efa\u7ebf\u7a0b\u5c40\u90e8\u53d8\u91cf\u7684 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-10007054","post","type-post","status-publish","format-standard","hentry","category-share"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10007054","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10007054"}],"version-history":[{"count":0,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10007054\/revisions"}],"wp:attachment":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10007054"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10007054"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10007054"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}