{"id":764,"date":"2018-11-28T02:34:38","date_gmt":"2018-11-27T23:34:38","guid":{"rendered":"http:\/\/delimuhendis.org\/?p=764"},"modified":"2022-12-20T21:11:26","modified_gmt":"2022-12-20T21:11:26","slug":"multithreading-1","status":"publish","type":"post","link":"https:\/\/www.delimuhendis.org\/?p=764","title":{"rendered":"Java ile Multithreading \u0130\u015flemleri-1"},"content":{"rendered":"\n<p>Merhaba Arkada\u015flar, bug\u00fcn size Java ile multithreading i\u015flemlerinden bahsedece\u011fim. Genelde sadece main thread \u00fczerine \u00e7al\u0131\u015fan programlar, paralel programlar\u0131 ile geli\u015ftirilmi\u015f programlardan \u00e7o\u011fu zaman daha yava\u015f \u00e7al\u0131\u015f\u0131r. Tabi ki bu sizin olu\u015fturabildi\u011finiz kadar thread olu\u015fturman\u0131z anlam\u0131na gelmez. \u00c7\u00fcnk\u00fc makinan\u0131n i\u015flemcisi de bellidir, \u00e7ekirde\u011fi de&#8230; Bu rakam tamamen i\u015flemciyle do\u011fru orant\u0131l\u0131d\u0131r ve i\u015f y\u00fck\u00fc optimum miktarda thread&#8217;e b\u00f6l\u00fcnmelidir.<\/p>\n\n\n\n<p>A\u015fa\u011f\u0131daki s\u0131n\u0131f\u0131m\u0131z bizim ilk thread s\u0131n\u0131f\u0131m\u0131z olacak ve run() methodu da thread \u00e7al\u0131\u015ft\u0131r\u0131ld\u0131\u011f\u0131nda \u00e7al\u0131\u015facak i\u015flemleri i\u00e7erir.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">class SampleThread extends Thread\n{\n    public void run()\n    {\n        System.out.println(\"Hello World\");\n    }\n}<\/pre>\n\n\n\n<p>Main methodumuzda 5 adet thread olu\u015fturuyoruz, ba\u015flat\u0131yoruz ve hepsi ba\u015flat\u0131ld\u0131ktan sonra join i\u015flemlerini yaparak senkronize \u00e7al\u0131\u015fmay\u0131 sa\u011fl\u0131yoruz.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">public class Main\n{\n    static SampleThread [] sampleThreads;\n    public static void main(String[] args)\n    {\n        Main.sampleThreads = new SampleThread[5];\n        for (int i = 0; i &lt; Main.sampleThreads.length; i++)\n        {\n            SampleThread thread = new SampleThread();\n            thread.start();\n            Main.sampleThreads[i] = thread;\n        }\n\n        for(int i = 0; i &lt; Main.sampleThreads.length;i++)\n        {\n            try\n            {\n                Main.sampleThreads[i].join();\n            }\n            catch (InterruptedException e)\n            {\n                e.printStackTrace();\n            }\n        }\n    }\n}<\/pre>\n\n\n\n<p>Sonu\u00e7<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Hello World\nHello World\nHello World\nHello World\nHello World\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Merhaba Arkada\u015flar, bug\u00fcn size Java ile multithreading i\u015flemlerinden bahsedece\u011fim. Genelde sadece main thread \u00fczerine \u00e7al\u0131\u015fan programlar, paralel programlar\u0131 ile geli\u015ftirilmi\u015f&hellip;<\/p>\n","protected":false},"author":1,"featured_media":1390,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[302,307,395,558],"class_list":["post-764","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-programlama","tag-java","tag-join","tag-multithreading","tag-thread"],"_links":{"self":[{"href":"https:\/\/www.delimuhendis.org\/index.php?rest_route=\/wp\/v2\/posts\/764","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.delimuhendis.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.delimuhendis.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.delimuhendis.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.delimuhendis.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=764"}],"version-history":[{"count":1,"href":"https:\/\/www.delimuhendis.org\/index.php?rest_route=\/wp\/v2\/posts\/764\/revisions"}],"predecessor-version":[{"id":1357,"href":"https:\/\/www.delimuhendis.org\/index.php?rest_route=\/wp\/v2\/posts\/764\/revisions\/1357"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.delimuhendis.org\/index.php?rest_route=\/wp\/v2\/media\/1390"}],"wp:attachment":[{"href":"https:\/\/www.delimuhendis.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=764"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.delimuhendis.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=764"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.delimuhendis.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=764"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}