Click here to Skip to main content
16,011,436 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Regex! Pin
Tim Smith16-Mar-02 12:06
Tim Smith16-Mar-02 12:06 
GeneralSuppress user input Pin
16-Mar-02 10:25
suss16-Mar-02 10:25 
GeneralRe: Suppress user input Pin
Morozov Alexey16-Mar-02 20:08
Morozov Alexey16-Mar-02 20:08 
GeneralShow/hide toolbars Pin
Stew16-Mar-02 10:04
Stew16-Mar-02 10:04 
GeneralRe: Show/hide toolbars Pin
Derek Waters17-Mar-02 12:28
Derek Waters17-Mar-02 12:28 
GeneralFrequency Generator Pin
Peter Liddle16-Mar-02 9:21
Peter Liddle16-Mar-02 9:21 
GeneralOCR Pin
16-Mar-02 7:24
suss16-Mar-02 7:24 
GeneralMultithread question repost...... Pin
16-Mar-02 7:06
suss16-Mar-02 7:06 
Hi,

I read the MSDN online and get the following sample of using AfxBeginThread:

UINT MyThreadProc( LPVOID pParam )
{
CMyObject* pObject = (CMyObject*)pParam;

if (pObject == NULL ||
!pObject->IsKindOf(RUNTIME_CLASS(CMyObject)))
return 1; // if pObject is not valid

// do something with 'pObject'

return 0; // thread completed successfully
}

// inside a different function in the program
.
.
.
pNewObject = new CMyObject;
AfxBeginThread(MyThreadProc, pNewObject);
.
.
.


I understand that.....but :

I need to create 50 separate threads (liked 50 different transactions). Since my program is going to simulate the DBMS behavior, in the MyThreadProc() there should be some algorithm to choose whether the current operation of this transaction is READ or WRITE. In this case, all 50 threads will use the same MyThreadProc() and i don't need to make 50 different MyThreadProc(). My question is,

1. Can i create these thread by:

for (i=0; i<50; i++)
{
pNewObject = new CMyObject;
AfxBeginThread(MyThreadProc, pNewObject);
}

2. How to identify Xth thread after creating 50 threads?

3. What parameter I need to put in order to suspend/resume/kill the 10th (or Xth) Thread? Because let say, one thread A (transaction) is READING a data object, and another thread B wants to WRITE the same data object. In this case, thread B needs to wait until thread A finish. So I have to suspend thread B......and wait....then resume.

So, should I call AfxGetThread()???? SuspendThread()??? ResumeThread()????

I need sample codes or examples for each of the above questions. Can anyone help me... please?????

Thanks!!!!
Poke tongue | ;-P Poke tongue | ;-P Poke tongue | ;-P Poke tongue | ;-P
GeneralRe: Multithread question repost...... Pin
Michael Dunn16-Mar-02 7:41
sitebuilderMichael Dunn16-Mar-02 7:41 
GeneralRe: Multithread question repost...... Pin
Morozov Alexey16-Mar-02 20:15
Morozov Alexey16-Mar-02 20:15 
QuestionHow do i get a handle from Desktop ? Pin
CryoGate16-Mar-02 4:51
CryoGate16-Mar-02 4:51 
AnswerRe: How do i get a handle from Desktop ? Pin
Christopher Duncan16-Mar-02 7:30
Christopher Duncan16-Mar-02 7:30 
QuestionDrawing caption in dialog, who can help me? Pin
generic_user_id16-Mar-02 4:46
generic_user_id16-Mar-02 4:46 
AnswerRe: Drawing caption in dialog, who can help me? Pin
Paul M Watt16-Mar-02 6:35
mentorPaul M Watt16-Mar-02 6:35 
GeneralRe: Drawing caption in dialog, who can help me? Pin
generic_user_id16-Mar-02 8:10
generic_user_id16-Mar-02 8:10 
GeneralRe: Drawing caption in dialog, who can help me? Pin
Paul M Watt16-Mar-02 11:13
mentorPaul M Watt16-Mar-02 11:13 
QuestionHow to make the menu of XP's style ? Pin
mzt16-Mar-02 3:54
mzt16-Mar-02 3:54 
AnswerRe: How to make the menu of XP's style ? Pin
16-Mar-02 4:55
suss16-Mar-02 4:55 
QuestionHow to make the sensitive effect of mouse of CTabCtrl's push-button ? Pin
mzt16-Mar-02 3:49
mzt16-Mar-02 3:49 
GeneralCopy Constructors & operator= when using pointers Pin
John Cruz16-Mar-02 3:13
John Cruz16-Mar-02 3:13 
GeneralRe: Copy Constructors & operator= when using pointers Pin
Paul M Watt16-Mar-02 6:30
mentorPaul M Watt16-Mar-02 6:30 
GeneralSDK problem! Pin
hph16-Mar-02 3:13
hph16-Mar-02 3:13 
GeneralRe: SDK problem! Pin
Nish Nishant16-Mar-02 3:17
sitebuilderNish Nishant16-Mar-02 3:17 
GeneralRe: SDK problem! Pin
Peter Liddle16-Mar-02 9:25
Peter Liddle16-Mar-02 9:25 
GeneralSimple question Pin
John Cruz16-Mar-02 1:41
John Cruz16-Mar-02 1: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.