using threads?
how do you use threads in making a win32 application? is it as simple as using threads in java because that''s the only thing i know about threads?
There''re two kinds of threads on Win32 platform: one is worker thread; the other is UI thread. Normally, we use a worker thread to process data and request on the back ground.
A worker thread is formed by a normal routine.
e.g.
DWORD MyThread(LPVOID param)
{
....
}
Two methods in Windows Programming are employed to create threads: _beginthread and CreateThread. The former is the C run-time library function, but the rest is Win32 API. It can be easilier implemented in VC than in Java.
David
zwdavid@hotmail.com
A worker thread is formed by a normal routine.
e.g.
DWORD MyThread(LPVOID param)
{
....
}
Two methods in Windows Programming are employed to create threads: _beginthread and CreateThread. The former is the C run-time library function, but the rest is Win32 API. It can be easilier implemented in VC than in Java.
David
zwdavid@hotmail.com
Threads are pretty much the same in all languages, though that''s not so on different OSs.
Does Java only run on preemptive OSs?
Does Java only run on preemptive OSs?
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
Actually when counting thread API:s WinNT also support posix threads which is kind of nice since that's a standard also supported by different UN*Xes (== increased portability of the code). To bad Win9x doesn't support them.
pcvsee:
The basic goes something like (using _beginthread()):
void MyThread(void *args)
{
// do thread stuff
}
void StartMyThread()
{
HANDLE hThread = (HANDLE)_beginthread(MyThread, 0, NULL);
// do some more stuff
// then wait for the thread to exit
WaitForSingleObject(hThread, INFINITE);
}
But multi-thread programming is complicated stuff, so I recommend reading a good book or so on the subject.
/Andreas
Edited by - amag on January 15, 2001 1:06:23 PM
pcvsee:
The basic goes something like (using _beginthread()):
void MyThread(void *args)
{
// do thread stuff
}
void StartMyThread()
{
HANDLE hThread = (HANDLE)_beginthread(MyThread, 0, NULL);
// do some more stuff
// then wait for the thread to exit
WaitForSingleObject(hThread, INFINITE);
}
But multi-thread programming is complicated stuff, so I recommend reading a good book or so on the subject.
/Andreas
Edited by - amag on January 15, 2001 1:06:23 PM
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement