Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > Visual C++
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Visual C++ Questions specific to Microsoft's Visual C++. For questions not specific to this Microsoft version, use the C++ Programming forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual C++ section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 13th, 2004, 10:52 PM
Authorized User
 
Join Date: Aug 2004
Location: , , .
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default Accessing data from two threads

Hello,

I am writing an application which uses two threads.
I have a list<int> variable in my Document class.
THREAD 1
In this thread, I am filling a list from back i.e pDoc->list.insert(list.begin(),data);
THREAD 2
In this thread, I am extracting each element from top of the list, and displaying it on the UserInterface i.e
data = pDoc->list.pop_front();
Display(data);

THREAD1 cotinously reads and adds data at the bottom of the list while THREAD 2 gets data from the top of the list and displays it.

Can I directly access the list memeber available in my document class as above in the two threads.
When I tried the above, it worked fine when the list had limited number say 10 to 30 records, but as the size of list was growing to say 10,000 records the program was crashing.

Can anyone please help me to solve this ?

Thanks
Madhavi



Reply With Quote
  #2 (permalink)  
Old September 14th, 2004, 06:59 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma
Default

pop_front removes the data (first elements) so the second thread must have some machanism of checking that the data is there bofore trying to get the subsequent first elements.

Also posting some code always help the people who are willing to solve your problem.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sharing a data structure across multiple threads ravishakya Pro Java 1 October 9th, 2006 08:32 PM
Accessing data on the clipboard. voneimin Javascript How-To 7 March 5th, 2004 11:30 PM
accessing data from Excel chikodi Servlets 1 July 31st, 2003 12:17 AM
Problems with threads. Threads disappearing? DriesNeyrinck VB.NET 0 June 10th, 2003 08:26 AM



All times are GMT -4. The time now is 04:36 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.