473,473 Members | 1,831 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

how to use semaphore in this situation

bajajv
152 New Member
Hi, I have 5 producer threads and 10 consumer threads. 2 consumer threads for each producer.

How can I use a semaphore here, so that no 2 threads wanting to interact with same producer thread get access?

Thanks
May 5 '12 #1
4 1799
weaknessforcats
9,208 Recognized Expert Moderator Expert
There is a design pattern named Observer where you can implement a one-to-many relatonship. That pattern employs a change manager which is often implemented using another design pattern named Mediator.

The Mediator will manage the access to the target thread allowing only one client to access the target at any one time.
May 5 '12 #2
bajajv
152 New Member
Thanks for the help.

I will start with it now.
May 5 '12 #3
weaknessforcats
9,208 Recognized Expert Moderator Expert
Be sure to post back and let me know how it goes.
May 7 '12 #4
bajajv
152 New Member
Sure. Will definitely like to know how efficient my design goes.. :)
May 7 '12 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Saqib Ali | last post by:
Check out the following code fragment Line 1: myDict = {} Line 2: a = 5 Line 3: b = 2 Line 4: c = 0 Line 5: myDict = a + b + c Line 6: myDict = a - b - c Line 7: myDict = a * b * c...
4
by: Philip | last post by:
Hi, I am going to develop a piece of software in .NET that could concievably use an Access MDB file as a backbone for its datastore. Then I could use ADO.NET to get the data (it's kind of like...
1
by: davidw | last post by:
Please help, I am following a microsoft sample to build a dll, the instruction like this: To build the interop 1. From a command prompt, run \Program Files\Microsoft Visual Studio...
2
by: Alex | last post by:
Hello, I have a rather large table in MS SQL 2000 that I'm writing reports in Crystal from, but I'm unsure how to get the various data files (from different departments) into the table. Below...
7
by: pachanga | last post by:
Last week, I got a promotion to a higher position with new responsibilities and new supervisor. My supervisor ask me about a new position opening, and I took the position, but I totally forgot to...
3
by: davidw | last post by:
I created my own WebControl, I am thinking a way to put some logics in the class to a seperated class, and it will be accessed by all instances of my WebControl, the idea is that the class doesn;t...
5
by: Andrew S. Giles | last post by:
I thought I would post here, as I am sure someone, somewhere has run into this problem, and might have a good solution for me. I am writing an applicaiton in C# that will accept data and then put...
4
by: Guch Wu | last post by:
I want to design an image processing class as follow: class Image { Image Data; General Image Operations; read(filename, File_Type); write(filename, File_Type); };
14
by: Mohamed Mansour | last post by:
Hey there, this will be somewhat a long post, but any response is appreciated! I have done many PInvoke in the past from C++ to C#, but I did PInvoke within C# not C++/CLI. Can someone explain...
0
by: Juha Nieminen | last post by:
If I'm not mistaken, general OOP wisdom says that upcasting should usually be avoided if possible. I have a situation, however, where I can't think of a better way than upcasting for this specific...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.