I have 2 threads. One thread prints odd numbers and the
second thread prints even numbers. Now, I have to execute
the threads alternatively so that i can output 1,2,3,4,5,6,.....
write code for this?
Answer / bala narasimha reddy
Static nNum = 1;
CEvent cs(False, False);
AfxBeginThread(PrintOdd, 0);
AfxBeginThread(PrintEven, 0);
Void PrintOdd(LPVOID pParam)
{
CString str;
while( s <= MAXNUM)
{
cs.lock();
str.Format("%d",nNum);
nNum ++;
outputdebugstring(str);
cs.setEvent();
}
}
Void PrintEven(LPVOID pParam)
{
CString str;
while( s <= MAXNUM)
{
cs.lock();
str.Format("%d",nNum);
nNum ++;
outputdebugstring(str);
cs.setEvent();
}
}
Is This Answer Correct ? | 5 Yes | 7 No |
General purpose classes in MFC
2.create for 10 batch: Employee_Number Employee_name Employee_Dateofjoining Employee_address Employee_salary 1.select the employee name who deriving more than 10 thousand salary and joined before august 08. use structure and pointers
What is difference between the TCP/IP and UDP socket
What is the difference between GetMessage and PeekMessage ?
How to handle command line arguements from simple MFC application ?
what do you mean by psychic window?
how many types of classes are ther,what are that
i have created runtime menu -- ( admistrator ->managepackage,manage module). but now i want to open a dialog when i select manage package and any other diaolg when selecting manage module ( whole selection is at run time only ) . Please HELP .its urgently required
What is the initial function to be called in MFC and what it will do
Types of DLL's
what message is sent to an application when the user presses the primary button?
what is the meaning of constant FILE EXCEEDS LENGTH LIMIT while loading from ps file to vsam in the jcl?