{"id":849,"date":"2022-07-07T01:12:52","date_gmt":"2022-07-07T01:12:52","guid":{"rendered":"https:\/\/scrutineer.co.kr\/wordpress\/?p=849"},"modified":"2022-07-07T01:55:01","modified_gmt":"2022-07-07T01:55:01","slug":"%ec%93%b0%eb%a0%88%eb%93%9c-%eb%a1%9c%ec%bb%ac","status":"publish","type":"post","link":"https:\/\/scrutineer.co.kr\/wordpress\/index.php\/2022\/07\/07\/%ec%93%b0%eb%a0%88%eb%93%9c-%eb%a1%9c%ec%bb%ac\/","title":{"rendered":"\uc4f0\ub808\ub4dc \ub85c\uceec"},"content":{"rendered":"\n<h1 class=\"wp-block-heading\">\ub3d9\uc2dc\uc131 \ubb38\uc81c<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\uc218\ub3c4\ucf54\ub4dc\ub294 \ub2e4\uc74c\uacfc \uac19\ub2e4.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">@Controller\npublic class MyController {\n    private final MyService myService;\n\n    @Get(\"\/hello-number\")\n    public String hello(@RequestParam long num) {\n        myService.doService(num);\n    }\n}\n\n@Slf4j\n@Service\npublic class MyService {\n    \n    private Long beanVariable;\n\n    public void doService(Long num) {\n        beanVariable = num;\n        sleep(5000); \/\/ \uc784\uc758\ub85c \ub123\uc740 \uc2a4\ub808\ub4dc \uc2ac\ub9bd \uc2dc\uac04.\n        log.info(\"current Number value is : {}\", beanVariable);\n    }\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\ud754-\ud55c \uc6f9\uc11c\ube44\uc2a4 \ucee8\ud2b8\ub864\ub7ec + \uc11c\ube44\uc2a4 \uad6c\uc870. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\uc11c\ube44\uc2a4\uc5d0 classVariable \ub77c\ub294 \ubcc0\uc218\uac00 \uc788\ub2e4.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\uc800 \uad6c\uc870\uc5d0\uc11c \/hello-number \ub97c \uc2ac\ub9bd \uc2dc\uac04\uc778 5\ucd08 \ub0b4\uc5d0 \uc5f0\uc18d\uc73c\ub85c \ub530\ub531 \uc694\ub807\uac8c \ub54c\ub9ac\uba74 \uc5b4\ub5bb\uac8c \ub420\uae4c? (\uc784\uc758\ub85c \uc2ac\ub9bd\uc744 5\ucd08\ub098 \uc900 \uc774\uc720)<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\/hello-number?num=1<\/li><li>\/hello-number?num=2<\/li><li>\/hello-number?num=3<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">(\uc218\ub3c4\ucf54\ub4dc\ub77c \uc548\ud574\ubd24\uc9c0\ub9cc) \ub85c\uadf8\ub294 \uc694\ub807\uac8c \ub5a8\uc5b4\uc9c4\ub2e4.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">2022.07.07. 00:00:00 [Thread - 1] current Number value is : 3\n2022.07.07. 00:00:02 [Thread - 2] current Number value is : 3\n2022.07.07. 00:00:04 [Thread - 3] current Number value is : 3<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\uc65c \uadf8\ub7f4\uae4c<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\ub3d9\uc2dc\uc131 \ubb38\uc81c\ub54c\ubb38\uc774\ub2e4.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\ub3d9\uc2dc\uc131 \ubb38\uc81c\uac00 \ubb34\uc2a8 \uc18c\ub9ac\ub0d0 \ud558\uba74&#8230;<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\uae30\ubcf8\uc801\uc73c\ub85c \ucd5c\ucd08 \uc218\ub3c4\ucf54\ub4dc\uc758 \uad6c\uc870\ub85c \uc2a4\ud504\ub9c1 \uc5b4\ud50c\ub9ac\ucf00\uc774\uc158\uc744 \ub744\uc6b0\uba74,<br>\ucee8\ud2b8\ub864\ub7ec\ub3c4, \uc11c\ube44\uc2a4\ub3c4 \ucef4\ud3ec\ub10c\ud2b8 \uc5b4\ub178\ud14c\uc774\uc158(@Controller, @Service)\uc744 \ub2ec\uc558\uae30 \ub54c\ubb38\uc5d0 Bean\uc774 \uc0dd\uc131\ub418\uace0, <br>\uc774 Bean\ub4e4\uc740 \uc2a4\ud504\ub9c1 \ucee8\ud14c\uc774\ub108\uc5d0 \uc758\ud574\uc11c \uad00\ub9ac\ub41c\ub2e4.<\/li><li>\uac1c\ubc1c\uc790\uac00 \uc5b4\ub178\ud14c\uc774\uc158\uc744 \ud1b5\ud574 \ucef4\ud3ec\ub10c\ud2b8\ub77c\uace0 \ub4f1\ub85d\ud558\uace0, \uc2a4\ud504\ub9c1 \ucee8\ud14c\uc774\ub108\uac00 \uad00\ub9ac\ud558\ub294 Bean\uc740 \uae30\ubcf8\uc801\uc73c\ub85c &#8216;\uc2f1\uae00\ud1a4&#8217;\uc774\ub2e4.<\/li><li>\uadf8\ub9ac\uace0 \uc2a4\ud504\ub9c1 \ubd80\ud2b8\uc5d0\uc11c \uc0ac\uc6a9\ud558\ub294 \ud1b0\ucea3\uc740, \ud558\ub098\uc758 \uc694\uccad\uc744, &#8216;\ud504\ub85c\uc138\uc2a4&#8217; \uac00 \uc544\ub2cc &#8216;\uc2a4\ub808\ub4dc&#8217; \ub97c \ud1b5\ud574\uc11c \ucc98\ub9ac\ub97c \ud55c\ub2e4<ul><li>\ud1b0\ucea3 \uad6c\ub3d9\uc2dc\uc5d0 \uc124\uc815(\uc548\ud588\uc73c\uba74 \uae30\ubcf8\uc124\uc815)\ud55c \uc2a4\ub808\ub4dc \ud480\uc5d0\uc11c \uc2a4\ub808\ub4dc\ub97c \uaebc\ub0b4\uc640\uc11c \uc2e4\ud589.<\/li><\/ul><ul><li>\ud504\ub85c\uc138\uc2a4\ub85c \ub744\uc6b0\uac70\ub098 \ud558\ub294 \ubbf8\uce5c WAS\uac00 \uc788\uae34 \ud560\ub791\uac00..<\/li><\/ul><\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\uadf8\ub798\uc11c, \uc2a4\ud504\ub9c1 \uc5b4\ud50c\ub9ac\ucf00\uc774\uc158\uc744 \ub744\uc6b0\uac8c \ub418\uba74<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>MyService Bean\uc774 \ud55c\uac1c.<ul><li>\ub530\ub77c\uc11c MyService.beanVariable \ub3c4 (\ub2f9\uc5f0\ud788)\ud55c\uac1c.<\/li><\/ul><\/li><li>\uc9e7\uc740 \uc2dc\uac04(??)\uc5d0 \ud55c\uaebc\ubc88\uc5d0 \ubc1b\uc740 \uc218\ub9ce\uc740 \uc694\uccad\uc744 \uba40\ud2f0\uc2a4\ub808\ub4dc\ub85c \ucc98\ub9ac\ud558\uc5ec, <br>\uacb0\uad6d\uc5d4 MyService.beanVariable \ubcc0\uc218\uc5d0 \uc811\uadfc\uc744 \ud558\ub294\ub370, \uc5ec\uae30\uc11c \uc77c\uc885\uc758 race condition \uc774 \ubc1c\uc0dd\ud558\uc5ec &#8216;\uacf5\uc6a9 \uc790\uc6d0\uc744 \ub3d9\uc2dc\uc5d0 \uc811\uadfc\ud558\ub294&#8217; \ubd88\uc0c1\uc0ac\uac00 \ubc1c\uc0dd&#8230;<ul><li>\uc0ac\uc6a9\uc790\ub85c\ubd80\ud130 \uc694\uccad\uc740 \uac01\uac01 1,2,3 \uc73c\ub85c \ubc1b\uc558\uc73c\ub098, \uc815\uc791 \ucc98\ub9ac\ub294 3,3,3 \uc73c\ub85c \ucc98\ub9ac<\/li><\/ul><\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\b<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\ud574\uacb0\ubc29\ubc95<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">\uac1c\uc778\uc801\uc73c\ub85c\ub294 \uc560\ucd08\uc5d0 \uadf8\ub0e5 \uc800 beanVariable\uac19\uc740\uac78 \uc0ac\uc6a9\ud558\uc9c0 \uc54a\uac8c \ucef4\ud3ec\ub10c\ud2b8 \uc790\uccb4\uc5d0 \ud074\ub798\uc2a4 \ubcc0\uc218\ub97c \uc0ac\uc6a9\ud558\uc9c0 \uc54a\uac8c \ucf54\ub529\uc744 \ud558\ub294\uac8c 3\uc5b5\ubc30 \ub0ab\ub2e4\uace0 \uc0dd\uac01\ud55c\ub2e4.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\ub0b4\uac00 \uc2dd\uacac\uc774 \uc9e7\uace0 \ud574\uc654\ub358 \uc77c\ub9cc \ud574\uc11c \uadf8\ub7f0\uac00, \uc0ac\uc2e4 bean\uc5d0 \uc885\uc18d\ub41c \uc800\ub7f0 \uc804\uc5ed\uc131 \ubcc0\uc218\ub97c \uc0ac\uc6a9\ud558\ub294 \ucf00\uc774\uc2a4\ub3c4 \uc798 \ubabb\ubd24\ub2e4.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\uadfc\ub370, \uadf8\ub7fc\uc5d0\ub3c4 \ubd88\uad6c\ud558\uace0 \uc5b8\uc820\uac00 \uc0ac\uc6a9\ud574\uc57c \ud560 \uc0c1\ud669\uc774 \uc628\ub2e4\uba74&#8230;.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">ThreadLocal \uc744 \uc0ac\uc6a9\ud558\uba74 \ub41c\ub2e4.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\ub531 \ubd10\ub3c4 \ub124\uc774\ubc0d\uc774 &#8216;\uc2a4\ub808\ub4dc \ub85c\uceec&#8217;&#8230; \ub85c\uceec \uc2a4\ub808\ub4dc\uc5d0\ub9cc \ud560\ub2f9\ub418\ub294 \uc800\uc7a5\uc18c\ub77c\ub294 \ub290\ub08c\uc774 \ud30d\ud30d \ub4e4\uc9c0 \uc54a\ub294\uac00..<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\uc0ac\uc6a9\ubc95\uc740 \ucd08 \uac04\ub2e8\ud558\ub2e4&#8230; \uadf8\ub0e5 \uc608\uc81c\ub9cc\uc73c\ub85c\ub3c4 \uc124\uba85\uc774 \ub420 \uc9c0\uacbd\uc784<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">@Controller\npublic class MyController {\n    private final MyService myService;\n\n    @Get(\"\/hello-number\")\n    public String hello(@RequestParam long num) {\n        myService.doService(num);\n    }\n}\n\n@Slf4j\n@Service\npublic class MyService {\n    \n    private ThreadLocal&lt;Long> threadLocalVariable = new ThreadLocal&lt;>(); \/\/ \uc2a4\ub808\ub4dc\ub85c\uceec \uc0dd\uc131!!\n\n    public void doService(Long num) {\n        threadLocalVariable.set(num); \/\/ \uc14b!!!!!!!!!!!\n        sleep(5000);\n        log.info(\"current Number value is : {}\", threadLocalVariable.get()); \/\/ \uac9f!!!!!!!!!!!\n    }\n\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\uc774\uc81c, \uc544\uae4c\uc640 \ub611\uac19\uc774 \/hello-number \ub97c \uc5f0\uc18d\uc73c\ub85c \ub530\ub531 \ub54c\ub9ac\uba74 \uc5b4\ub5bb\uac8c \ub420\uae4c?<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\/hello-number?num=1<\/li><li>\/hello-number?num=2<\/li><li>\/hello-number?num=3<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">(\uc694\uac83\ub3c4 \uc77c\uc885\uc758 \uc218\ub3c4\ucf54\ub4dc\ub77c \uc548\ud574\ubd24\uc9c0\ub9cc) \ub85c\uadf8\ub294 \uc694\ub807\uac8c \ub5a8\uc5b4\uc9c4\ub2e4.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">2022.07.07. 00:01:00 [Thread - 1] current Number value is : 1\n2022.07.07. 00:01:02 [Thread - 2] current Number value is : 2\n2022.07.07. 00:01:04 [Thread - 3] current Number value is : 3<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\ub3d9\uc2dc\uc131 \ubb38\uc81c \uc218\ub3c4\ucf54\ub4dc\ub294 \ub2e4\uc74c\uacfc \uac19\ub2e4. \ud754-\ud55c \uc6f9\uc11c\ube44\uc2a4 \ucee8\ud2b8\ub864\ub7ec + \uc11c\ube44\uc2a4 \uad6c\uc870. \uc11c\ube44\uc2a4\uc5d0 classVariable \ub77c\ub294 \ubcc0\uc218\uac00 \uc788\ub2e4. \uc800 \uad6c\uc870\uc5d0\uc11c \/hello-number \ub97c \uc2ac\ub9bd \uc2dc\uac04\uc778 5\ucd08 \ub0b4\uc5d0 \uc5f0\uc18d\uc73c\ub85c \ub530\ub531 \uc694\ub807\uac8c \ub54c\ub9ac\uba74 \uc5b4\ub5bb\uac8c \ub420\uae4c? (\uc784\uc758\ub85c \uc2ac\ub9bd\uc744 5\ucd08\ub098 \uc900 \uc774\uc720) \/hello-number?num=1 \/hello-number?num=2 \/hello-number?num=3 (\uc218\ub3c4\ucf54\ub4dc\ub77c \uc548\ud574\ubd24\uc9c0\ub9cc) \ub85c\uadf8\ub294 \uc694\ub807\uac8c \ub5a8\uc5b4\uc9c4\ub2e4. \uc65c \uadf8\ub7f4\uae4c \ub3d9\uc2dc\uc131 \ubb38\uc81c\ub54c\ubb38\uc774\ub2e4. \ub3d9\uc2dc\uc131 \ubb38\uc81c\uac00 \ubb34\uc2a8 \uc18c\ub9ac\ub0d0 \ud558\uba74&#8230; \uae30\ubcf8\uc801\uc73c\ub85c \ucd5c\ucd08 \uc218\ub3c4\ucf54\ub4dc\uc758 &#8230; <a title=\"\uc4f0\ub808\ub4dc \ub85c\uceec\" class=\"read-more\" href=\"https:\/\/scrutineer.co.kr\/wordpress\/index.php\/2022\/07\/07\/%ec%93%b0%eb%a0%88%eb%93%9c-%eb%a1%9c%ec%bb%ac\/\" aria-label=\"Read more about \uc4f0\ub808\ub4dc \ub85c\uceec\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-849","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/scrutineer.co.kr\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/849","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/scrutineer.co.kr\/wordpress\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/scrutineer.co.kr\/wordpress\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/scrutineer.co.kr\/wordpress\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/scrutineer.co.kr\/wordpress\/index.php\/wp-json\/wp\/v2\/comments?post=849"}],"version-history":[{"count":6,"href":"https:\/\/scrutineer.co.kr\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/849\/revisions"}],"predecessor-version":[{"id":856,"href":"https:\/\/scrutineer.co.kr\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/849\/revisions\/856"}],"wp:attachment":[{"href":"https:\/\/scrutineer.co.kr\/wordpress\/index.php\/wp-json\/wp\/v2\/media?parent=849"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/scrutineer.co.kr\/wordpress\/index.php\/wp-json\/wp\/v2\/categories?post=849"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/scrutineer.co.kr\/wordpress\/index.php\/wp-json\/wp\/v2\/tags?post=849"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}