Solved

Sharring variables between multiple threads.

Posted on 2006-06-15
2
256 Views
Last Modified: 2010-04-16
Hi Experts,

      I need to know the right way of sharing data between different threads.  I have a main thread which is going to spawn about 10 different instances of the same worker thread.  These worker threads are going to collect information and put them each into a seperate instance (or array member) of the same structure.  So I would like to end up with an array of the structure (myStructure[10]) whose members were populated by ten different threads simultaniously.  What's the excepted way of doing something like this?

Thanks,
axnst2
0
Comment
Question by:axnst2
2 Comments
 
LVL 12

Accepted Solution

by:
gbzhhu earned 500 total points
Comment Utility
Basically, there is no magic on this other than ensuring only 1 thrwead is accessing your structure at any given 1 time.  There are a few ways of doing this using thread synchronization keywords amd classes.  The following article explains better, read all 4 pages

http://www.ondotnet.com/pub/a/dotnet/2001/08/06/csharp.html?page=1
0
 

Author Comment

by:axnst2
Comment Utility
Thanks!  That'll be useful!
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

771 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

11 Experts available now in Live!

Get 1:1 Help Now