Ron James
2003-07-03 01:34:12 UTC
During the course of debugging a thread memory leak, I
wrote this trivial program. It's based on an MFC Dialog
based wizard generated program. it doesn't do much of
course, and doesn't leak memory, but what interests me is
the DEBUG Output window, a sample of which follows.
Question. Why are some threads labelled 'Win32 Thread'
and others '_threadstartex'. Are they really different in
some way? I want to use MFC classes in the thread. Will
all threads support MFC classes?
Thanks.
The thread 'Win32 Thread' (0xd34) has exited with code 0
(0x0).
The thread 'Win32 Thread' (0x6d8) has exited with code 0
(0x0).
The thread 'Win32 Thread' (0x1198) has exited with code 0
(0x0).
The thread '_threadstartex' (0x18f8) has exited with code
0 (0x0).
The thread 'Win32 Thread' (0x8c8) has exited with code 0
(0x0).
The thread 'Win32 Thread' (0x18c4) has exited with code 0
(0x0).
The thread 'Win32 Thread' (0x7f4) has exited with code 0
(0x0).
The thread 'Win32 Thread' (0x400) has exited with code 0
(0x0).
The thread '_threadstartex' (0x1810) has exited with code
0 (0x0).
The thread 'Win32 Thread' (0xaa8) has exited with code 0
(0x0).
The thread 'Win32 Thread' (0x1814) has exited with code 0
(0x0).
The thread 'Win32 Thread' (0x190c) has exited with code 0
(0x0).
The program '[6104] testThread.exe: Native' has exited
with code 0 (0x0).
// Button Handler
void CtestThreadDlg::OnBnClickedTestthread()
{
::AfxBeginThread( ThreadFunction, GetSafeHwnd() );
}
// Handle WM_THREADEND message
LRESULT CtestThreadDlg::OnThreadEnd(WPARAM wParam, LPARAM
lParam) {
static int iCount = 10;
if ( --iCount ) {
::AfxBeginThread( ThreadFunction,
GetSafeHwnd() );
}
return 0L;
}
// Static Thread function
UINT CtestThreadDlg::ThreadFunction( LPVOID lParam ) {
HWND hWnd = static_cast<HWND>( lParam );
::Sleep(250);
// Notify the creating window that we've finished
::PostMessage( hWnd, WM_THREADEND, 0, 0 );
return 0;
}
wrote this trivial program. It's based on an MFC Dialog
based wizard generated program. it doesn't do much of
course, and doesn't leak memory, but what interests me is
the DEBUG Output window, a sample of which follows.
Question. Why are some threads labelled 'Win32 Thread'
and others '_threadstartex'. Are they really different in
some way? I want to use MFC classes in the thread. Will
all threads support MFC classes?
Thanks.
The thread 'Win32 Thread' (0xd34) has exited with code 0
(0x0).
The thread 'Win32 Thread' (0x6d8) has exited with code 0
(0x0).
The thread 'Win32 Thread' (0x1198) has exited with code 0
(0x0).
The thread '_threadstartex' (0x18f8) has exited with code
0 (0x0).
The thread 'Win32 Thread' (0x8c8) has exited with code 0
(0x0).
The thread 'Win32 Thread' (0x18c4) has exited with code 0
(0x0).
The thread 'Win32 Thread' (0x7f4) has exited with code 0
(0x0).
The thread 'Win32 Thread' (0x400) has exited with code 0
(0x0).
The thread '_threadstartex' (0x1810) has exited with code
0 (0x0).
The thread 'Win32 Thread' (0xaa8) has exited with code 0
(0x0).
The thread 'Win32 Thread' (0x1814) has exited with code 0
(0x0).
The thread 'Win32 Thread' (0x190c) has exited with code 0
(0x0).
The program '[6104] testThread.exe: Native' has exited
with code 0 (0x0).
// Button Handler
void CtestThreadDlg::OnBnClickedTestthread()
{
::AfxBeginThread( ThreadFunction, GetSafeHwnd() );
}
// Handle WM_THREADEND message
LRESULT CtestThreadDlg::OnThreadEnd(WPARAM wParam, LPARAM
lParam) {
static int iCount = 10;
if ( --iCount ) {
::AfxBeginThread( ThreadFunction,
GetSafeHwnd() );
}
return 0L;
}
// Static Thread function
UINT CtestThreadDlg::ThreadFunction( LPVOID lParam ) {
HWND hWnd = static_cast<HWND>( lParam );
::Sleep(250);
// Notify the creating window that we've finished
::PostMessage( hWnd, WM_THREADEND, 0, 0 );
return 0;
}