Solved

Connecting Threads

Posted on 1998-11-13
3
185 Views
Last Modified: 2011-09-20
Im having a progran in c++ witch makes two kinds of threads , lets call them VeThreads and CuThreads.Each kind has many threads identified uniqelly by a certain key.This key can be found only Twice : first time on the VeThreads and the second time on the CuThreads making them a pair of threads.
I want to pass information between those two threads.
these two threads are made after a connection is made ,  each thread with a different network server.
How do I make this?
Should I use Events?
Is link list a correct way to keep the information need to be passed (there is a possibility that few threads of CuThreads are made before the VeThreads made or viseversa )
and if so how do I make it?
Please give me a full answer include a code example.
Thank you.
Uri
0
Comment
Question by:uri22
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 

Expert Comment

by:umzilber
ID: 1177829
Sounds like you need a Semaphore or a Monitor.

0
 
LVL 2

Accepted Solution

by:
abesoft earned 90 total points
ID: 1177830
I think you might want to create an additional level of organization, like a thread-pair manager.  The manager would be a C++ class containing a shared memory area that is protected by a mutex, and it would pass a pointer to itself to the two threads that it spawns.  These threads could send messages back and forth using the manager object.

I would design fns in the thread-manager to SendMessage, CheckMessage, and GetMessage, that would actually get the lock, move the data, and release the lock.

Hope this helps
0
 
LVL 1

Author Comment

by:uri22
ID: 1177831
abesoft thank you for your answer.
I would like to receive a code example for your suggestion.
I will increase points !!!
uri22.
0

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question