{"id":133556,"date":"2024-03-26T04:07:47","date_gmt":"2024-03-25T19:07:47","guid":{"rendered":"https:\/\/www.silicloud.com\/ja\/blog\/pthread-%e3%81%ae-linux-%e3%81%a7%e3%81%ae%e4%bd%bf%e3%81%84%e6%96%b9\/"},"modified":"2024-04-05T06:27:48","modified_gmt":"2024-04-04T21:27:48","slug":"pthread-%e3%81%ae-linux-%e3%81%a7%e3%81%ae%e4%bd%bf%e3%81%84%e6%96%b9","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/ja\/blog\/pthread-%e3%81%ae-linux-%e3%81%a7%e3%81%ae%e4%bd%bf%e3%81%84%e6%96%b9\/","title":{"rendered":"pthread \u306e Linux \u3067\u306e\u4f7f\u3044\u65b9"},"content":{"rendered":"<p>Linux\u3067\u306f\u3001pthread\u306f\u30de\u30eb\u30c1\u30b9\u30ec\u30c3\u30c9\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u7528\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u3059\u3002\u4ee5\u4e0b\u306f\u3001pthread\u3092\u4f7f\u7528\u3059\u308b\u305f\u3081\u306e\u57fa\u672c\u7684\u306a\u624b\u9806\u3067\u3059\u3002<\/p>\n<ol>\n<li>pthread.h \u30d8\u30c3\u30c0\u30d5\u30a1\u30a4\u30eb\u306e\u5305\u542b\uff1apthread \u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u95a2\u6570\u3084\u578b\u3092\u4f7f\u7528\u3059\u308b\u306b\u306f\u3001\u30bd\u30fc\u30b9\u30d5\u30a1\u30a4\u30eb\u306b `#include ` \u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/li>\n<li>\u30b9\u30ec\u30c3\u30c9\u306e\u4f5c\u6210: pthread_create \u95a2\u6570\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002\u3053\u306e\u95a2\u6570\u306f 4 \u3064\u306e\u5f15\u6570\u3092\u53d6\u308a\u307e\u3059: \u65b0\u3057\u3044\u30b9\u30ec\u30c3\u30c9 ID \u3092\u683c\u7d0d\u3059\u308b pthread_t \u578b\u3078\u306e\u30dd\u30a4\u30f3\u30bf\u3001\u65b0\u3057\u3044\u30b9\u30ec\u30c3\u30c9\u306e\u5c5e\u6027\u3092\u8a2d\u5b9a\u3059\u308b pthread_attr_t \u578b\u3078\u306e\u30dd\u30a4\u30f3\u30bf\u3001\u65b0\u3057\u3044\u30b9\u30ec\u30c3\u30c9\u306e\u958b\u59cb\u95a2\u6570\u3078\u306e\u95a2\u6570\u30dd\u30a4\u30f3\u30bf\u3001\u65b0\u3057\u3044\u30b9\u30ec\u30c3\u30c9\u306e\u5f15\u6570\u3068\u3057\u3066\u306e void \u30dd\u30a4\u30f3\u30bf<\/li>\n<\/ol>\n<p>\u305f\u3068\u3048\u3070<\/p>\n<pre class=\"post-pre\"><code><span class=\"hljs-type\">pthread_t<\/span> thread_id;\r\n<span class=\"hljs-type\">int<\/span> ret = pthread_create(&amp;thread_id, <span class=\"hljs-literal\">NULL<\/span>, myThreadFunction, <span class=\"hljs-literal\">NULL<\/span>);\r\n<span class=\"hljs-keyword\">if<\/span> (ret != <span class=\"hljs-number\">0<\/span>) {\r\n<span class=\"hljs-comment\">\/\/ \u9519\u8bef\u5904\u7406<\/span>\r\n}\r\n<\/code><\/pre>\n<ol>\n<li>\u65b0\u898f\u30b9\u30ec\u30c3\u30c9\u306e\u30a8\u30f3\u30c8\u30ea\u95a2\u6570\u3092\u4f5c\u6210\u3059\u308b\uff1a\u65b0\u898f\u95a2\u6570\u3092\u65b0\u898f\u30b9\u30ec\u30c3\u30c9\u306e\u30a8\u30f3\u30c8\u30ea\u95a2\u6570\u3068\u3057\u3066\u4f5c\u6210\u3059\u308b\u3002\u3053\u306e\u95a2\u6570\u306f\u3001void\u30dd\u30a4\u30f3\u30bf\u578b\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u6301\u3061\u3001void\u30dd\u30a4\u30f3\u30bf\u578b\u306e\u7d50\u679c\u3092\u8fd4\u3059\u5fc5\u8981\u304c\u3042\u308b\u3002\u30a8\u30f3\u30c8\u30ea\u95a2\u6570\u5185\u3067\u65b0\u898f\u30b9\u30ec\u30c3\u30c9\u306e\u5177\u4f53\u7684\u306a\u30ed\u30b8\u30c3\u30af\u3092\u5b9f\u88c5\u3059\u308b\u3002<\/li>\n<\/ol>\n<p>\u4f8b\u3048\u3070\uff1a<\/p>\n<pre class=\"post-pre\"><code><span class=\"hljs-type\">void<\/span>* <span class=\"hljs-title function_\">myThreadFunction<\/span><span class=\"hljs-params\">(<span class=\"hljs-type\">void<\/span>* arg)<\/span> {\r\n<span class=\"hljs-comment\">\/\/ \u7ebf\u7a0b\u903b\u8f91<\/span>\r\n<span class=\"hljs-keyword\">return<\/span> <span class=\"hljs-literal\">NULL<\/span>;\r\n}\r\n<\/code><\/pre>\n<ol>\n<li>pthread_join<\/li>\n<\/ol>\n<p>\u4f8b\u3048\u3070<\/p>\n<pre class=\"post-pre\"><code><span class=\"hljs-type\">void<\/span>* thread_result;\r\n<span class=\"hljs-type\">int<\/span> ret = pthread_join(thread_id, &amp;thread_result);\r\n<span class=\"hljs-keyword\">if<\/span> (ret != <span class=\"hljs-number\">0<\/span>) {\r\n<span class=\"hljs-comment\">\/\/ \u9519\u8bef\u5904\u7406<\/span>\r\n}\r\n<\/code><\/pre>\n<ol>\n<li>pthread_exit<\/li>\n<\/ol>\n<p>\u305f\u3068\u3048\u3070:<\/p>\n<pre class=\"post-pre\"><code>pthread_exit(<span class=\"hljs-literal\">NULL<\/span>);\r\n<\/code><\/pre>\n<p>\u4ee5\u4e0a\u306fpthread\u3092\u4f7f\u3046\u57fa\u672c\u30b9\u30c6\u30c3\u30d7\u3067\u3059\u304c\u3001\u30b9\u30ec\u30c3\u30c9\u540c\u671f\u3001\u6392\u4ed6\u5236\u5fa1\u3001\u6761\u4ef6\u5909\u6570\u306a\u3069\u3001\u3088\u308a\u9ad8\u5ea6\u306apthread\u95a2\u6570\u304c\u307b\u304b\u306b\u3082\u3042\u308a\u307e\u3059\u3002pthread\u3092\u4f7f\u3046\u5834\u5408\u306f\u3001\u30b9\u30ec\u30c3\u30c9\u306e\u540c\u671f\u3068\u30ea\u30bd\u30fc\u30b9\u306e\u7af6\u5408\u306e\u554f\u984c\u306b\u6ce8\u610f\u3057\u3001\u30a8\u30e9\u30fc\u3084\u4e0d\u78ba\u5b9f\u306a\u52d5\u4f5c\u304c\u8d77\u3053\u3089\u306a\u3044\u3088\u3046\u306b\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Linux\u3067\u306f\u3001pthread\u306f\u30de\u30eb\u30c1\u30b9\u30ec\u30c3\u30c9\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u7528\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u3059\u3002\u4ee5\u4e0b\u306f\u3001pthread\u3092\u4f7f\u7528\u3059\u308b\u305f\u3081\u306e\u57fa\u672c\u7684\u306a\u624b\u9806\u3067\u3059\u3002 pthread.h \u30d8\u30c3\u30c0\u30d5\u30a1\u30a4\u30eb\u306e\u5305\u542b\uff1apthread \u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u95a2\u6570\u3084\u578b\u3092\u4f7f [&hellip;]<\/p>\n","protected":false},"author":6,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-133556","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>pthread \u306e Linux \u3067\u306e\u4f7f\u3044\u65b9 - Blog - Silicon Cloud<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/ja\/blog\/pthread-\u306e-linux-\u3067\u306e\u4f7f\u3044\u65b9\/\" \/>\n<meta property=\"og:locale\" content=\"ja_JP\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"pthread \u306e Linux \u3067\u306e\u4f7f\u3044\u65b9\" \/>\n<meta property=\"og:description\" content=\"Linux\u3067\u306f\u3001pthread\u306f\u30de\u30eb\u30c1\u30b9\u30ec\u30c3\u30c9\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u7528\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u3059\u3002\u4ee5\u4e0b\u306f\u3001pthread\u3092\u4f7f\u7528\u3059\u308b\u305f\u3081\u306e\u57fa\u672c\u7684\u306a\u624b\u9806\u3067\u3059\u3002 pthread.h \u30d8\u30c3\u30c0\u30d5\u30a1\u30a4\u30eb\u306e\u5305\u542b\uff1apthread \u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u95a2\u6570\u3084\u578b\u3092\u4f7f [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/ja\/blog\/pthread-\u306e-linux-\u3067\u306e\u4f7f\u3044\u65b9\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2024-03-25T19:07:47+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-04T21:27:48+00:00\" \/>\n<meta name=\"author\" content=\"\u6d77\u6597, \u8475\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u57f7\u7b46\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u6d77\u6597, \u8475\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/pthread-%e3%81%ae-linux-%e3%81%a7%e3%81%ae%e4%bd%bf%e3%81%84%e6%96%b9\/\",\"url\":\"https:\/\/www.silicloud.com\/ja\/blog\/pthread-%e3%81%ae-linux-%e3%81%a7%e3%81%ae%e4%bd%bf%e3%81%84%e6%96%b9\/\",\"name\":\"pthread \u306e Linux \u3067\u306e\u4f7f\u3044\u65b9 - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#website\"},\"datePublished\":\"2024-03-25T19:07:47+00:00\",\"dateModified\":\"2024-04-04T21:27:48+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/20cfc053626f4d45c0fa7a4e7964b5b6\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/pthread-%e3%81%ae-linux-%e3%81%a7%e3%81%ae%e4%bd%bf%e3%81%84%e6%96%b9\/#breadcrumb\"},\"inLanguage\":\"ja\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/ja\/blog\/pthread-%e3%81%ae-linux-%e3%81%a7%e3%81%ae%e4%bd%bf%e3%81%84%e6%96%b9\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/pthread-%e3%81%ae-linux-%e3%81%a7%e3%81%ae%e4%bd%bf%e3%81%84%e6%96%b9\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/ja\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"pthread \u306e Linux \u3067\u306e\u4f7f\u3044\u65b9\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/ja\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"ja\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/20cfc053626f4d45c0fa7a4e7964b5b6\",\"name\":\"\u6d77\u6597, \u8475\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ja\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/25aec9a18954b6bfb7e4f7219c2923d62c6f0c9f4d5c0171228fe41751c0ab7a?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/25aec9a18954b6bfb7e4f7219c2923d62c6f0c9f4d5c0171228fe41751c0ab7a?s=96&d=mm&r=g\",\"caption\":\"\u6d77\u6597, \u8475\"},\"url\":\"https:\/\/www.silicloud.com\/ja\/blog\/author\/kaitoaoi\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"ja\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/pthread-%e3%81%ae-linux-%e3%81%a7%e3%81%ae%e4%bd%bf%e3%81%84%e6%96%b9\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"pthread \u306e Linux \u3067\u306e\u4f7f\u3044\u65b9 - Blog - Silicon Cloud","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/ja\/blog\/pthread-\u306e-linux-\u3067\u306e\u4f7f\u3044\u65b9\/","og_locale":"ja_JP","og_type":"article","og_title":"pthread \u306e Linux \u3067\u306e\u4f7f\u3044\u65b9","og_description":"Linux\u3067\u306f\u3001pthread\u306f\u30de\u30eb\u30c1\u30b9\u30ec\u30c3\u30c9\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u7528\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u3059\u3002\u4ee5\u4e0b\u306f\u3001pthread\u3092\u4f7f\u7528\u3059\u308b\u305f\u3081\u306e\u57fa\u672c\u7684\u306a\u624b\u9806\u3067\u3059\u3002 pthread.h \u30d8\u30c3\u30c0\u30d5\u30a1\u30a4\u30eb\u306e\u5305\u542b\uff1apthread \u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u95a2\u6570\u3084\u578b\u3092\u4f7f [&hellip;]","og_url":"https:\/\/www.silicloud.com\/ja\/blog\/pthread-\u306e-linux-\u3067\u306e\u4f7f\u3044\u65b9\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2024-03-25T19:07:47+00:00","article_modified_time":"2024-04-04T21:27:48+00:00","author":"\u6d77\u6597, \u8475","twitter_card":"summary_large_image","twitter_misc":{"\u57f7\u7b46\u8005":"\u6d77\u6597, \u8475"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/ja\/blog\/pthread-%e3%81%ae-linux-%e3%81%a7%e3%81%ae%e4%bd%bf%e3%81%84%e6%96%b9\/","url":"https:\/\/www.silicloud.com\/ja\/blog\/pthread-%e3%81%ae-linux-%e3%81%a7%e3%81%ae%e4%bd%bf%e3%81%84%e6%96%b9\/","name":"pthread \u306e Linux \u3067\u306e\u4f7f\u3044\u65b9 - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/ja\/blog\/#website"},"datePublished":"2024-03-25T19:07:47+00:00","dateModified":"2024-04-04T21:27:48+00:00","author":{"@id":"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/20cfc053626f4d45c0fa7a4e7964b5b6"},"breadcrumb":{"@id":"https:\/\/www.silicloud.com\/ja\/blog\/pthread-%e3%81%ae-linux-%e3%81%a7%e3%81%ae%e4%bd%bf%e3%81%84%e6%96%b9\/#breadcrumb"},"inLanguage":"ja","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/ja\/blog\/pthread-%e3%81%ae-linux-%e3%81%a7%e3%81%ae%e4%bd%bf%e3%81%84%e6%96%b9\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/ja\/blog\/pthread-%e3%81%ae-linux-%e3%81%a7%e3%81%ae%e4%bd%bf%e3%81%84%e6%96%b9\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/ja\/blog\/"},{"@type":"ListItem","position":2,"name":"pthread \u306e Linux \u3067\u306e\u4f7f\u3044\u65b9"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/ja\/blog\/#website","url":"https:\/\/www.silicloud.com\/ja\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"ja"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/20cfc053626f4d45c0fa7a4e7964b5b6","name":"\u6d77\u6597, \u8475","image":{"@type":"ImageObject","inLanguage":"ja","@id":"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/25aec9a18954b6bfb7e4f7219c2923d62c6f0c9f4d5c0171228fe41751c0ab7a?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/25aec9a18954b6bfb7e4f7219c2923d62c6f0c9f4d5c0171228fe41751c0ab7a?s=96&d=mm&r=g","caption":"\u6d77\u6597, \u8475"},"url":"https:\/\/www.silicloud.com\/ja\/blog\/author\/kaitoaoi\/"},{"@type":"ImageObject","inLanguage":"ja","@id":"https:\/\/www.silicloud.com\/ja\/blog\/pthread-%e3%81%ae-linux-%e3%81%a7%e3%81%ae%e4%bd%bf%e3%81%84%e6%96%b9\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts\/133556","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/comments?post=133556"}],"version-history":[{"count":2,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts\/133556\/revisions"}],"predecessor-version":[{"id":312540,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts\/133556\/revisions\/312540"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/media?parent=133556"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/categories?post=133556"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/tags?post=133556"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}