Solved

Need Worker Threading Example

Posted on 2001-08-20
2
1,089 Views
Last Modified: 2013-11-20
Can anyone provide me a sample hello world liked code that demostrate the usage of threading by using the following class :

AfxBeginThread class
CMutex
CSingle
CMultilock

thank you.
0
Comment
Question by:yccheok
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 50 total points
ID: 6409764
0
 
LVL 3

Expert Comment

by:GlennDean
ID: 6411732
CMutex * gpMutex = NULL;
CSingleLock * gpSingleLock = NULL;
UINT GetBufRelBufThread( LPVOID pParam );

void CSemaphoreExView::OnOptionsStartTest()
{
  gpMutex = new CMutex(FALSE);  //Not owned state
  ASSERT(gpMutex);
  gpLock = new CMySingleLock(m_pMutex,FALSE);
  ASSERT(gpLock);

  for (int i=0;i<100;i++)
  {
    AfxBeginThread(GetBufRelBufThread,NULL);
  }
}

UINT GetBufRelBufThread( LPVOID pParam )
{
  //Access some resource that needs to be protected by a lock
  gpLock->Lock();  //INFINITE wait is the default

  //CODE HERE TO ACCESS THE RESOURCE

  gpLock->Unlock();
  return 0;
}

  Glenn
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Is it possible to combine several text files into one big one? (redhat v5 enterprise) 4 110
no14 challenge 14 73
Change to event 1 129
Problem to open Excel file 15 227
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question