Click here to Skip to main content
16,014,838 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: MFC + Threading = C2665 Pin
_AnsHUMAN_ 19-Mar-09 19:08
_AnsHUMAN_ 19-Mar-09 19:08 
AnswerRe: MFC + Threading = C2665 Pin
Sunil Lanke19-Mar-09 19:09
Sunil Lanke19-Mar-09 19:09 
QuestionAnother Post from Bob about Threads, Pointers and Locks[modified] Pin
BobInNJ19-Mar-09 10:45
BobInNJ19-Mar-09 10:45 
AnswerRe: Another Post from Bob about Threads and Points Pin
Code-o-mat19-Mar-09 12:31
Code-o-mat19-Mar-09 12:31 
GeneralRe: Another Post from Bob about Threads and Points Pin
BobInNJ19-Mar-09 12:39
BobInNJ19-Mar-09 12:39 
GeneralRe: Another Post from Bob about Threads and Points Pin
bulg19-Mar-09 13:39
bulg19-Mar-09 13:39 
GeneralRe: Another Post from Bob about Threads and Points Pin
BobInNJ19-Mar-09 13:58
BobInNJ19-Mar-09 13:58 
QuestionThreads and Pointers Pin
BobInNJ19-Mar-09 7:36
BobInNJ19-Mar-09 7:36 
I am currently developing a multi-threaded application using C++ and MFC. Each thread calls new and delete to allocate and free memory. I am wondering if this is ok. In particular, if I have a routine that does the following, is it thread safe?

<br />
void<br />
WorkerClass::genRandomNumbers( double *randomNumbers, int count )<br />
{	<br />
    double *ranList = new double[6];<br />
<br />
    // Do some work, details not shown<br />
<br />
    delete []ranList;<br />
}<br />


I am thinking that if two different threads are executing this routine at the same time, one might be allocating memory and the other freeing memory. Is that ok? One possibility is that Microsoft has put locks in there code to make sure that new and delete are thread safe. I have been unable to find documentation saying that they have or have not done this. I am hoping somebody out there can enlighten me on this issue.

Thanks

Bob
AnswerRe: Threads and Pointers Pin
led mike19-Mar-09 7:41
led mike19-Mar-09 7:41 
AnswerRe: Threads and Pointers Pin
Eytukan19-Mar-09 7:41
Eytukan19-Mar-09 7:41 
GeneralRe: Threads and Pointers Pin
led mike19-Mar-09 7:58
led mike19-Mar-09 7:58 
GeneralRe: Threads and Pointers Pin
Eytukan19-Mar-09 8:12
Eytukan19-Mar-09 8:12 
AnswerRe: Threads and Pointers Pin
CPallini19-Mar-09 7:46
mveCPallini19-Mar-09 7:46 
GeneralRe: Threads and Pointers Pin
led mike19-Mar-09 9:42
led mike19-Mar-09 9:42 
AnswerRe: Threads and Pointers Pin
cmk19-Mar-09 13:17
cmk19-Mar-09 13:17 
QuestionEdit control disappears from dialog [modified] Pin
rp_suman19-Mar-09 7:07
rp_suman19-Mar-09 7:07 
AnswerRe: Edit control disappears from dialog Pin
Code-o-mat19-Mar-09 7:27
Code-o-mat19-Mar-09 7:27 
QuestionC4244 conversion from 'double' to 'float' warning Pin
penny black19-Mar-09 6:47
penny black19-Mar-09 6:47 
AnswerRe: C4244 conversion from 'double' to 'float' warning Pin
Eytukan19-Mar-09 6:56
Eytukan19-Mar-09 6:56 
QuestionRe: C4244 conversion from 'double' to 'float' warning Pin
penny black19-Mar-09 7:02
penny black19-Mar-09 7:02 
AnswerRe: C4244 conversion from 'double' to 'float' warning [fixed] Pin
CPallini19-Mar-09 7:21
mveCPallini19-Mar-09 7:21 
GeneralRe: C4244 conversion from 'double' to 'float' warning Pin
Eytukan19-Mar-09 7:29
Eytukan19-Mar-09 7:29 
GeneralRe: C4244 conversion from 'double' to 'float' warning Pin
CPallini19-Mar-09 7:38
mveCPallini19-Mar-09 7:38 
GeneralRe: C4244 conversion from 'double' to 'float' warning Pin
penny black19-Mar-09 7:36
penny black19-Mar-09 7:36 
QuestionRe: C4244 conversion from 'double' to 'float' warning Pin
CPallini19-Mar-09 7:41
mveCPallini19-Mar-09 7:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.