% % This file was automatically produced at Feb 27 2003, 22:51:56 by % c2latex win-hello.c % \expandafter\ifx\csname indentation\endcsname\relax% \newlength{\indentation}\fi \setlength{\indentation}{0.5em} \begin{flushleft} {\tt \#include} $<${\tt{}windows.h}$>$ \mbox{}\\ {\tt \#include} $<${\tt{}stdio.h}$>$ \mbox{}\\ {\tt \#include} $<${\tt{}stdlib.h}$>$ \mbox{}\\ \mbox{}\\ {\tt \#define} NUM\_THREADS 5 \mbox{}\\ \mbox{}\\ DWORD WINAPI print\_hello( {\bf void} $\ast$threadid ) \mbox{}\\ \{ \mbox{}\\ \hspace*{8\indentation}printf( {\tt"$\backslash$n\%d: Hello World!$\backslash$n"}, threadid ); \mbox{}\\ \hspace*{8\indentation}{\bf return} 0; \mbox{}\\ \} \mbox{}\\ \mbox{}\\ {\bf int} main({\bf int} argc, {\bf char}$\ast$ argv[]) \mbox{}\\ \{ \mbox{}\\ \hspace*{8\indentation}DWORD threads[ NUM\_THREADS ]; \mbox{}\\ \hspace*{8\indentation}{\bf static} HANDLE handles[ NUM\_THREADS ]; \mbox{}\\ \hspace*{8\indentation}{\bf unsigned} {\bf int} t; \mbox{}\\ \hspace*{8\indentation}{\bf for} ( t = 0; t $<$ NUM\_THREADS; ++t ) \{ \mbox{}\\ \hspace*{16\indentation}printf( {\tt"Creating thread \%d$\backslash$n"}, t ); \mbox{}\\ \hspace*{16\indentation}handles[ t ] = CreateThread( NULL, 0, \mbox{}\\ \hspace*{22\indentation}( LPTHREAD\_START\_ROUTINE ) print\_hello, \mbox{}\\ \hspace*{22\indentation}( LPVOID ) t, 0, (LPDWORD) \&threads[ t ] ); \mbox{}\\ \hspace*{16\indentation}{\bf if} ( ! handles[ t ] ) \{ \mbox{}\\ \hspace*{24\indentation}printf( {\tt"Error: failed to create process \%d$\backslash$n"}, t ); \mbox{}\\ \hspace*{24\indentation}exit( 1 ); \mbox{}\\ \hspace*{16\indentation}\} \mbox{}\\ \hspace*{8\indentation}\} \mbox{}\\ \hspace*{8\indentation}WaitForMultipleObjects( NUM\_THREADS, handles, 1, INFINITE ); \mbox{}\\ \hspace*{8\indentation}{\bf return} 0; \mbox{}\\ \} \mbox{}\\ \mbox{}\\ \end{flushleft}