#### Archived

This topic is now archived and is closed to further replies.

## Recommended Posts

WebsiteWill    134
Does CreateThread not give a unique handle to every thread that is created? In other words, wouldn''t the following code create 4 unique threads each with a unique HANDLE and push that handle onto the vector vRecvThreadPool? The reason I ask is that the cout statement following the call to push the handle onto the vector always outputs the exact same thing: 0x00000000. I''m trying to debug this program. It runs but this output just seems peculiar.
for (iThreadCount=0; iThreadCount < 4;
{
reinterpret_cast< LPVOID >(pRecv),
{
exit(1);
}

}

Another problem that is generating an actual error is my actual thread function (worker function). In that function, if I make any call to an STL object the program crashes. Are STL objects not thread safe? For now I am only running the program with a single thread and only that thread does anything with the queue in question so it shouldn''t be an issue of multiple threads mangling the memory. Example: if(vRecvThreadPool.size() == 1) { cout << "GOOD UNTIL HERE" << endl; } will genenerate a runtime error (program dies) but if(1<2) { cout << "GOOD UNTIL HERE" << endl; } will work just fine. All of my errors are isolated around STL objects I am using. Whether it''s a call to .size(), .push_back(), or whatever. Should I be using a critical section or a mutex around these no matter if I only have 1 thread or more? Thanks for any help, Webby

cbenoi1    484

Hmmmmm....

-cb

##### Share on other sites
Nerusai    103
quote:
Original post by cbenoi1

Hmmmmm....

-cb

If you missed this:

It should be ==, since you''re comparing.

##### Share on other sites
WebsiteWill    134
Ahhhh, the joys of the little mistakes that bite you in the ass

Still got the issues with the STL objects though.

Thanks guys. Can''t believe I missed that one...

Webby