{"id":4468,"date":"2014-03-30T11:23:21","date_gmt":"2014-03-30T11:23:21","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/what-is-non-thread-safety-for-collection-of-common-programming-errors\/"},"modified":"2014-03-30T11:23:21","modified_gmt":"2014-03-30T11:23:21","slug":"what-is-non-thread-safety-for-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/what-is-non-thread-safety-for-collection-of-common-programming-errors\/","title":{"rendered":"What is non-thread-safety for?-Collection of common programming errors"},"content":{"rendered":"<blockquote>\n<p>So, what is the point of keeping non thread-safe code?<\/p>\n<\/blockquote>\n<p>By allowing for code that isn&#8217;t thread safe you&#8217;re leaving it up to the <strong>programmer to decide what the correct level of isolation is.<\/strong><\/p>\n<p>As others have mentioned this allows for complexity reduction and improved performance.<\/p>\n<p>Rico Mariani wrote two articles entitled &#8220;Putting your synchronization at the correct level&#8221; and Putting your synchronization at the correct level &#8212; solution that have a nice example of this in action.<\/p>\n<p>In the article he has a method called <code>DoWork()<\/code>. In it he calls another classes <code>Read<\/code> 2x <code>Write<\/code> 2x and then <code>LogToSteam<\/code>.<\/p>\n<p><code>Read<\/code>, <code>Write<\/code>, and <code>LogToSteam<\/code> all shared lock a lock and where thread safe. Except of course because <code>DoWork<\/code> was also thread safe. This meant all the synchronizing work in each <code>Read<\/code>, <code>Write<\/code> and <code>LogToSteam<\/code> was a complete waste of time.<\/p>\n<p>This is all due to the nature Imperative Programming. It side effects cause this.<\/p>\n<p>However if you had an development platform where applications could be expressed as pure functions where there were no dependencies or side effects then it would be possible to create applications where the threading was managed without developer intervention.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So, what is the point of keeping non thread-safe code? By allowing for code that isn&#8217;t thread safe you&#8217;re leaving it up to the programmer to decide what the correct level of isolation is. As others have mentioned this allows for complexity reduction and improved performance. Rico Mariani wrote two articles entitled &#8220;Putting your synchronization [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4468","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4468","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4468"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4468\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4468"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4468"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4468"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}