<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://www.programmingexamples.net/w/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://www.programmingexamples.net/w/index.php?action=history&amp;feed=atom&amp;title=CPP%2FBoost%2FThreadCommunication</id>
		<title>CPP/Boost/ThreadCommunication - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://www.programmingexamples.net/w/index.php?action=history&amp;feed=atom&amp;title=CPP%2FBoost%2FThreadCommunication"/>
		<link rel="alternate" type="text/html" href="http://www.programmingexamples.net/w/index.php?title=CPP/Boost/ThreadCommunication&amp;action=history"/>
		<updated>2026-06-15T12:41:53Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.23.5</generator>

	<entry>
		<id>http://www.programmingexamples.net/w/index.php?title=CPP/Boost/ThreadCommunication&amp;diff=390&amp;oldid=prev</id>
		<title>Daviddoria: Created page with '==ThreadCommunication.cpp== &lt;source lang=&quot;cpp&quot;&gt; #include &lt;iostream&gt; #include &lt;vector&gt;  #include &lt;boost/thread/thread.hpp&gt;  class CSharedData { public:     CSharedData() : data(0)…'</title>
		<link rel="alternate" type="text/html" href="http://www.programmingexamples.net/w/index.php?title=CPP/Boost/ThreadCommunication&amp;diff=390&amp;oldid=prev"/>
				<updated>2010-11-30T17:37:33Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;#039;==ThreadCommunication.cpp== &amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt; #include &amp;lt;iostream&amp;gt; #include &amp;lt;vector&amp;gt;  #include &amp;lt;boost/thread/thread.hpp&amp;gt;  class CSharedData { public:     CSharedData() : data(0)…&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==ThreadCommunication.cpp==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;vector&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;boost/thread/thread.hpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
class CSharedData&lt;br /&gt;
{&lt;br /&gt;
public:&lt;br /&gt;
    CSharedData() : data(0) { }&lt;br /&gt;
&lt;br /&gt;
    void send (int m)&lt;br /&gt;
    {&lt;br /&gt;
      data = m;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    int receive()&lt;br /&gt;
    {&lt;br /&gt;
      return data;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
private:&lt;br /&gt;
    int data;&lt;br /&gt;
&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
CSharedData SharedData;&lt;br /&gt;
&lt;br /&gt;
void sender()&lt;br /&gt;
{&lt;br /&gt;
  SharedData.send(21);&lt;br /&gt;
  int data = SharedData.receive();&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;Data in sender: &amp;quot; &amp;lt;&amp;lt; data &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void receiver()&lt;br /&gt;
{&lt;br /&gt;
  int n = 0;&lt;br /&gt;
  while (n &amp;lt; 100000000)&lt;br /&gt;
  {&lt;br /&gt;
    ++n;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  int data = SharedData.receive();&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;Data in receiver: &amp;quot; &amp;lt;&amp;lt; data &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main(int, char*[])&lt;br /&gt;
{&lt;br /&gt;
  boost::thread thrd1(&amp;amp;sender);&lt;br /&gt;
  boost::thread thrd2(&amp;amp;receiver);&lt;br /&gt;
&lt;br /&gt;
  thrd1.join();&lt;br /&gt;
  thrd2.join();&lt;br /&gt;
&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==CMakeLists.txt==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
cmake_minimum_required(VERSION 2.6)&lt;br /&gt;
&lt;br /&gt;
Project(ThreadCommunication)&lt;br /&gt;
&lt;br /&gt;
ADD_EXECUTABLE(ThreadCommunication ThreadCommunication.cpp)&lt;br /&gt;
TARGET_LINK_LIBRARIES(ThreadCommunication boost_thread-mt)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Daviddoria</name></author>	</entry>

	</feed>