{"id":9097940,"date":"2017-05-04T17:20:28","date_gmt":"2017-05-04T17:20:28","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/wordpress-and-pthreads\/"},"modified":"2017-05-04T17:20:28","modified_gmt":"2017-05-04T17:20:28","slug":"wordpress-and-pthreads","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/wordpress-and-pthreads\/","title":{"rendered":"WordPress and pthreads"},"content":{"rendered":"<p>Hi, I know this is probably not a good idea but I want to know how to make this work anyway. In a WordPress plugin I have the following code.<\/p>\n<pre><code>class Test_WP extends Thread {\n    public function run() {\n        update_option(&#039;test&#039;, &#039;two&#039;);\n    }\n}\n\nupdate_option(&#039;test&#039;, &#039;one&#039;);\n\n$test_wp = new Test_WP();\n$test_wp-&gt;start();<\/code><\/pre>\n<p>The option in the database is set to &#8216;one&#8217;. If I call and require wp&#8211;load.php in the thread it makes no difference, I thought the thread might not have access to the WP functions but no errors have been generated.<\/p>\n<p>Any ideas on how to get WordPress multithreaded?<\/p>\n","protected":false},"template":"","class_list":["post-9097940","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/9097940","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/9097940\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=9097940"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}