How can i create a multithread in C for windows?

Here is a simple guide to winapi threads
http://www.cs.rpi.edu/academics/courses/netprog/WindowsThreads.html

That being said, C is a minimalistic language, does not have built-in threading like java (nor the enormous extra libraries). It was meant as a general language to build on top of it. On Unix-like systems there are system wide standard c libraries beyond the ANSI/ISO standard, which are part of the posix standard, the pthreads are posix-threads. Windows C libraries are MS makes things their own way. You can use frameworks that provides multi-OS support like glib or qt (Windows, Linux,other *nix). There are also ports and compatibility layers to use posix facilities inside windows. Cigwin gives you a full posix environment besides the libraries, The MinGW compiler allows you to use ports of posix functions on top of win32 layers.

Frameworks like glib and qt are best to keep your code multi-platform, they hide the OS specifics, allowing a more general approach.

glib is part of the GTK libraries for GUI development and QT is also a GUI development framework but in C++.


The tags suggest you're using Windows. The Win32 api has a CreateThread function that can be used to launch a new thread. However, when you're using the C runtime (which you are) then you should use the _beginthread function by including process.h.

The reason to use _beginthread is that it initializes thread specific state information that the C runtime requires to execute correctly within a thread.


If you're familiar with pthreads and/or want a cross-platform codebase, you can use MinGW and pthreads-win32. I've recently used it in an application of mine and it seems to work great. If you're developing exclusively for Windows, its probably worth your time to learn the WinAPI threading stuff as redcomet suggested.