Solved

Connecting Threads

Posted on 1998-11-13
3
179 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
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 be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

930 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now