{"id":66,"date":"2009-08-22T07:37:42","date_gmt":"2009-08-22T07:37:42","guid":{"rendered":"http:\/\/www.adriangrigoras.com\/blog\/?p=66"},"modified":"2009-08-22T07:37:42","modified_gmt":"2009-08-22T07:37:42","slug":"perl-and-treads","status":"publish","type":"post","link":"https:\/\/adriangrigoras.com\/blog\/perl-and-treads\/","title":{"rendered":"Perl and treads"},"content":{"rendered":"<p>Sometimes, you need to create other threads and let the main thread manage other threads.<\/p>\n<p>This is an example how to create a thread in Perl:<\/p>\n<address>\n<div id=\"_mcePaste\" style=\"position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;\">#!\/usr\/bin\/perl<\/div>\n<div id=\"_mcePaste\" style=\"position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;\">use threads;<\/div>\n<div id=\"_mcePaste\" style=\"position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;\">my $thr = threads-&gt;create(&#8216;test&#8217;);<\/div>\n<div id=\"_mcePaste\" style=\"position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;\">sub test<\/div>\n<div id=\"_mcePaste\" style=\"position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;\">{<\/div>\n<div id=\"_mcePaste\" style=\"position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;\">REPEAT:<\/div>\n<div id=\"_mcePaste\" style=\"position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;\">print &#8220;This is a testn&#8221;;<\/div>\n<div id=\"_mcePaste\" style=\"position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;\">goto REPEAT;<\/div>\n<div id=\"_mcePaste\" style=\"position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;\">}<\/div>\n<blockquote>\n<address>#!\/usr\/bin\/perl<\/address>\n<address>use threads;<\/address>\n<address><\/address>\n<address>my $thr = threads-&gt;create(&#8216;test&#8217;);<\/address>\n<address><\/address>\n<address>sub test<\/address>\n<address>{<\/address>\n<address> REPEAT:<\/address>\n<address> print &#8220;This is a testn&#8221;;<\/address>\n<address> goto REPEAT;<\/address>\n<address>}<\/address>\n<\/blockquote>\n<\/address>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes, you need to create other threads and let the main thread manage other threads. This is an example how to create a thread in Perl: #!\/usr\/bin\/perl use threads; my $thr = threads-&gt;create(&#8216;test&#8217;); sub test { REPEAT: print &#8220;This is a testn&#8221;; goto REPEAT; } #!\/usr\/bin\/perl use threads; my $thr = threads-&gt;create(&#8216;test&#8217;); sub test {\u2026 <span class=\"read-more\"><a href=\"https:\/\/adriangrigoras.com\/blog\/perl-and-treads\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[],"class_list":["post-66","post","type-post","status-publish","format-standard","hentry","category-perl"],"_links":{"self":[{"href":"https:\/\/adriangrigoras.com\/blog\/wp-json\/wp\/v2\/posts\/66","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/adriangrigoras.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/adriangrigoras.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/adriangrigoras.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/adriangrigoras.com\/blog\/wp-json\/wp\/v2\/comments?post=66"}],"version-history":[{"count":0,"href":"https:\/\/adriangrigoras.com\/blog\/wp-json\/wp\/v2\/posts\/66\/revisions"}],"wp:attachment":[{"href":"https:\/\/adriangrigoras.com\/blog\/wp-json\/wp\/v2\/media?parent=66"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/adriangrigoras.com\/blog\/wp-json\/wp\/v2\/categories?post=66"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/adriangrigoras.com\/blog\/wp-json\/wp\/v2\/tags?post=66"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}