{"id":10342,"date":"2020-10-02T15:03:30","date_gmt":"2020-10-02T06:03:30","guid":{"rendered":"http:\/\/www.gisdeveloper.co.kr\/?p=10342"},"modified":"2020-10-05T07:10:34","modified_gmt":"2020-10-04T22:10:34","slug":"future-%ed%8c%a8%ed%84%b4","status":"publish","type":"post","link":"http:\/\/www.gisdeveloper.co.kr\/?p=10342","title":{"rendered":"Future \ud328\ud134"},"content":{"rendered":"<h4>\ud328\ud134 \uba85\uce6d<\/h4>\n<p>Future<\/p>\n<h4>\ud544\uc694\ud55c \uc0c1\ud669<\/h4>\n<p>\uc2a4\ub808\ub4dc\ub294 \ucf54\ub4dc\uc758 \uc2e4\ud589\uc5d0 \ucd08\uc810\uc774 \ub9de\ucdb0\uc838 \uc788\uace0, \uadf8 \uacb0\uacfc\ub97c \ubc1b\ub294 \uc2dc\uc810\uc774 \ubd88\ubd84\uba85\ud558\ub2e4. \uc2a4\ub808\ub4dc\uac00 \ub2e8\uc21c\ud788 \ucf54\ub4dc\ub97c \uc2e4\ud589\ud558\ub294 \uac83\uc5d0\uc11c \ub05d\ub098\ub294 \uac83\uc774 \uc544\ub2c8\ub77c \uadf8 \uc2e4\ud589\uc758 \uacb0\uacfc\ub97c \ub2e4\ub978 \uc2a4\ub808\ub4dc\uc5d0\uc11c \ubc1b\uae30 \uc704\ud55c \ud328\ud134\uc774\ub2e4.<\/p>\n<h4>\uc608\uc81c \ucf54\ub4dc<\/h4>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.gisdeveloper.co.kr\/wp-content\/uploads\/2020\/10\/future.png\" alt=\"\" width=\"1232\" height=\"702\" class=\"aligncenter size-full wp-image-10347\" \/><\/p>\n<p>Proxy \ud074\ub798\uc2a4\ub294 \uc5b4\ub5a4 \uacb0\uacfc\ub97c \uc5bb\uae30 \uc704\ud55c \ucf54\ub4dc\uc758 \uc2e4\ud589\uc744 \uc2a4\ub808\ub4dc\ub85c \uc2e4\ud589\ud574 \uc8fc\ub294 \ub300\ub9ac\uc790\uc774\ub2e4. Proxy\ub294 \uc5b4\ub5a4 \ucf54\ub4dc\uc758 \uc2e4\ud589\uc744 \uc2a4\ub808\ub4dc\ub85c \uc2e4\ud589\ud574\uc8fc\uace0 \ubc14\ub85c Result \ud074\ub798\uc2a4 \ud0c0\uc785\uc758 \uac1d\uccb4\ub97c \ubc18\ud658\ud55c\ub2e4. \ubc14\ub85c \uc774 Result\ub97c \ud1b5\ud574 \uc2a4\ub808\ub4dc\uc758 \uacb0\uacfc\ub97c \uc5bb\uc744 \uc218 \uc788\ub2e4. \uc2a4\ub808\ub4dc\uc758 \uc2e4\ud589 \uacb0\uacfc\ub97c \uc5bb\uc744 \uc218 \uc788\ub294 \uc0c1\ud0dc\uac00 \ub418\uba74 Result \uac1d\uccb4\uc758 setRealResult\ub97c \ud1b5\ud574 \uc2e4\uc81c \uacb0\uacfc\ub97c \ub2f4\ub294 RealResult \uac1d\uccb4\ub97c Result \ud074\ub798\uc2a4\uc758 \ud544\ub4dc\uac12\uc5d0 \ub2f4\ub294\ub2e4. \ucd94\ud6c4 \uc801\ub2f9\ud55c \uc2dc\uc810\uc5d0\uc11c Result \ud074\ub798\uc2a4\uc758 get \ud568\uc218\ub97c \ud638\ucd9c\ud574\uc11c \uc2e4\uc81c \uacb0\uacfc\ub97c \uc5bb\ub294\ub2e4. \ub9cc\uc57d \uc2e4\uc81c \uacb0\uacfc\ub97c \uc5bb\uc744 \uc218 \uc5c6\uc744 \ub54c\ub294 \uc2e4\uc81c \uacb0\uacfc\uac00 \uc644\uc131\ub420\ub54c\uae4c\uc9c0 get \ud568\uc218\ub294 \ub3d9\uae30\ud654(Blocking) \ub41c\ub2e4. \uc774\ub7ec\ud55c \ud074\ub798\uc2a4\ub4e4\uc744 \uc0ac\uc6a9\ud558\ub294 \ucf54\ub4dc\ub294 \uc544\ub798\uc640 \uac19\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\">\r\npackage tstThread;\r\n\r\npublic class Main {\r\n\tpublic static void main(String[] args) {\r\n\t\tSystem.out.println(\"START\");\r\n\t\t\r\n\t\tProxy proxy = new Proxy();\r\n\t\tResult result1 = proxy.run(10, 'A');\r\n\t\tResult result2 = proxy.run(30, 'B');\r\n\t\tResult result3 = proxy.run(20, 'C');\r\n\t\t\t\t\r\n\t\tSystem.out.println(\"result1 = \" + result1.get());\r\n\t\tSystem.out.println(\"result2 = \" + result2.get());\r\n\t\tSystem.out.println(\"result3 = \" + result3.get());\r\n\t\t\r\n\t\tSystem.out.println(\"END\");\r\n\t}\r\n}\r\n<\/pre>\n<p>Proxy \ud074\ub798\uc2a4\ub294 \ub2e4\uc74c\uacfc \uac19\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\">\r\npackage tstThread;\r\n\r\npublic class Proxy {\r\n\tpublic Result run(final int count, final char c) {\r\n\t\tfinal Result result = new Result();\r\n\t\t\r\n\t\tnew Thread() {\r\n\t\t\tpublic void run() {\r\n\t\t\t\tRealResult realData = new RealResult(count, c);\r\n\t\t\t\tresult.setRealResult(realData);\r\n\t\t\t}\r\n\t\t}.start();\r\n\t\t\r\n\t\treturn result;\r\n\t}\r\n}\r\n<\/pre>\n<p>Result \ud074\ub798\uc2a4\ub294 \ub2e4\uc74c\uacfc \uac19\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\">\r\npackage tstThread;\r\n\r\npublic class Result {\r\n\tprivate RealResult real = null;\r\n\t\r\n\tpublic synchronized void setRealResult(RealResult real) {\r\n\t\tif(this.real != null) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\t\r\n\t\tthis.real = real;\r\n\t\t\r\n\t\tnotifyAll();\r\n\t}\r\n\t\r\n\tpublic synchronized String get() {\r\n\t\twhile(real == null) {\r\n\t\t\ttry {\r\n\t\t\t\twait();\r\n\t\t\t} catch(InterruptedException e) {\r\n\t\t\t\t\/\/.\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\treturn real.get();\r\n\t}\r\n}\r\n<\/pre>\n<p>RealResult \ud074\ub798\uc2a4\ub294 \ub2e4\uc74c\uacfc \uac19\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\">\r\npackage tstThread;\r\n\r\npublic class RealResult extends Result {\r\n\tprivate final String resultData;\r\n\t\r\n\tpublic RealResult(int count, char c) {\r\n\t\tchar[] buffer = new char[count];\r\n\t\tfor(int i=0; i&lt;count; i++) {\r\n\t\t\tbuffer[i] = c;\r\n\t\t\ttry {\r\n\t\t\t\tThread.sleep(100);\r\n\t\t\t} catch(InterruptedException e) {\r\n\t\t\t\t\/\/.\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tthis.resultData = new String(buffer);\r\n\t}\r\n\t\r\n\t@Override\r\n\tpublic String get() {\r\n\t\treturn resultData;\r\n\t}\r\n}\r\n<\/pre>\n<p>\uc2e4\ud589 \uacb0\uacfc\ub294 \ub2e4\uc74c\uacfc \uac19\ub2e4.<\/p>\n<pre class='code'>\r\nSTART\r\nresult1 = AAAAAAAAAA\r\nresult2 = BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nresult3 = CCCCCCCCCCCCCCCCCCCC\r\nEND\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\ud328\ud134 \uba85\uce6d Future \ud544\uc694\ud55c \uc0c1\ud669 \uc2a4\ub808\ub4dc\ub294 \ucf54\ub4dc\uc758 \uc2e4\ud589\uc5d0 \ucd08\uc810\uc774 \ub9de\ucdb0\uc838 \uc788\uace0, \uadf8 \uacb0\uacfc\ub97c \ubc1b\ub294 \uc2dc\uc810\uc774 \ubd88\ubd84\uba85\ud558\ub2e4. \uc2a4\ub808\ub4dc\uac00 \ub2e8\uc21c\ud788 \ucf54\ub4dc\ub97c \uc2e4\ud589\ud558\ub294 \uac83\uc5d0\uc11c \ub05d\ub098\ub294 \uac83\uc774 \uc544\ub2c8\ub77c \uadf8 \uc2e4\ud589\uc758 \uacb0\uacfc\ub97c \ub2e4\ub978 \uc2a4\ub808\ub4dc\uc5d0\uc11c \ubc1b\uae30 \uc704\ud55c \ud328\ud134\uc774\ub2e4. \uc608\uc81c \ucf54\ub4dc Proxy \ud074\ub798\uc2a4\ub294 \uc5b4\ub5a4 \uacb0\uacfc\ub97c \uc5bb\uae30 \uc704\ud55c \ucf54\ub4dc\uc758 \uc2e4\ud589\uc744 \uc2a4\ub808\ub4dc\ub85c \uc2e4\ud589\ud574 \uc8fc\ub294 \ub300\ub9ac\uc790\uc774\ub2e4. Proxy\ub294 \uc5b4\ub5a4 \ucf54\ub4dc\uc758 \uc2e4\ud589\uc744 \uc2a4\ub808\ub4dc\ub85c \uc2e4\ud589\ud574\uc8fc\uace0 \ubc14\ub85c Result \ud074\ub798\uc2a4 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/www.gisdeveloper.co.kr\/?p=10342\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;Future \ud328\ud134&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-10342","post","type-post","status-publish","format-standard","hentry","category-design"],"_links":{"self":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/10342","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10342"}],"version-history":[{"count":5,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/10342\/revisions"}],"predecessor-version":[{"id":10350,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/10342\/revisions\/10350"}],"wp:attachment":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10342"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10342"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10342"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}