Click here to Skip to main content
15,899,754 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: is C++ programs portable?? Pin
Johnny ²24-Jan-04 21:40
Johnny ²24-Jan-04 21:40 
AnswerRe: is C++ programs portable?? Pin
toxcct25-Jan-04 22:44
toxcct25-Jan-04 22:44 
Generalstd::list question Pin
bneacetp24-Jan-04 15:31
bneacetp24-Jan-04 15:31 
GeneralRe: std::list question Pin
PJ Arends24-Jan-04 18:05
professionalPJ Arends24-Jan-04 18:05 
GeneralRe: std::list question Pin
bneacetp24-Jan-04 18:17
bneacetp24-Jan-04 18:17 
GeneralRe: std::list question Pin
bneacetp28-Jan-04 23:20
bneacetp28-Jan-04 23:20 
GeneralRe: std::list question Pin
PJ Arends31-Jan-04 6:00
professionalPJ Arends31-Jan-04 6:00 
Generalstatic member functions & multithreading Pin
Ernesto D.24-Jan-04 13:58
Ernesto D.24-Jan-04 13:58 
Hi all, here´s a "tricky" question.
let´s say i plan to use serveral threads on my app, so i write a class to wrap threads, its header could look something like this (in pseudo-code):

class CThread
{
public:
BOOL Start(); // called to create the thread
void End(); // called to terminate the thread

static DWORD WINAPI MyThreadProc(LPVOID pData); // the threadproc
};

and in my app i could create several of these at any given time, like:
void WhatEver()
{
CThread threads[5];
for(int i=0; i<5; i++)
threads[i].Start();
}

to my understanding, when a class has a static member function, one and ONLY ONE "instance" of that function´s code exsists in my application as soon as the app starts running, even if there are several instances of that class present, they all "share" the same Function code (right?)
so, there are (in the above code) 5 instances of the CThread class, but there is ONLY one instance of the MyThreadProc() function, so here´s what i dont understand, ¿what if the threads do some time consuming operation?, ¿how can threads[1] start "running" if threads[0] has´nt finished yet, and thread[2] do its stuff while thread[1] is busy and so on? or to put it in other words, if theres only one instance of MyThreadProc(), ¿how can it be used at the same time by all threads?

Thanks for reading!
GeneralRe: static member functions &amp; multithreading Pin
Michael Dunn24-Jan-04 19:01
sitebuilderMichael Dunn24-Jan-04 19:01 
GeneralRe: static member functions &amp; multithreading Pin
Ernesto D.26-Jan-04 12:04
Ernesto D.26-Jan-04 12:04 
GeneralRe: static member functions &amp; multithreading Pin
Michael Dunn26-Jan-04 12:30
sitebuilderMichael Dunn26-Jan-04 12:30 
GeneralRe: static member functions &amp; multithreading Pin
Gerald Schwab25-Jan-04 17:03
Gerald Schwab25-Jan-04 17:03 
GeneralRe: static member functions &amp; multithreading Pin
Ernesto D.26-Jan-04 12:02
Ernesto D.26-Jan-04 12:02 
GeneralSuspend Program Execution Pin
Daniel132424-Jan-04 13:17
Daniel132424-Jan-04 13:17 
GeneralRe: Suspend Program Execution Pin
wb25-Jan-04 4:31
wb25-Jan-04 4:31 
GeneralRe: Suspend Program Execution Pin
Daniel132425-Jan-04 7:43
Daniel132425-Jan-04 7:43 
GeneralStretchDIBits returns weird artifacts Pin
cnstrnd24-Jan-04 13:08
cnstrnd24-Jan-04 13:08 
GeneralRe: StretchDIBits returns weird artifacts Pin
CodeBrain25-Jan-04 21:53
CodeBrain25-Jan-04 21:53 
GeneralAccelerators Pin
Deian24-Jan-04 13:06
Deian24-Jan-04 13:06 
GeneralRe: Accelerators Pin
eugi25-Jan-04 0:55
eugi25-Jan-04 0:55 
GeneralRe: Accelerators Pin
Deian25-Jan-04 7:04
Deian25-Jan-04 7:04 
GeneralAccess Child Windows in IE Pin
gaz200424-Jan-04 12:24
sussgaz200424-Jan-04 12:24 
GeneralRe: Access Child Windows in IE Pin
Marcello25-Jan-04 11:11
Marcello25-Jan-04 11:11 
Generalerror LNK2001: unresolved external symbol &quot;public: __ Pin
BrockVnm24-Jan-04 9:44
BrockVnm24-Jan-04 9:44 
GeneralRe: error LNK2001: unresolved external symbol &quot;public: __ Pin
Amit Dey24-Jan-04 11:38
Amit Dey24-Jan-04 11:38 

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.