# Include <windows. h> # include <process. h>/* _ beginthread, _ endthread */# include <iostream> # include <fstream> # include <string> using namespace STD; ofstream out ("out.txt "); void threadfunc1 (pvoid PARAM) {While (1) {char * P; P = (char *) Param; sleep (10 ); out <p <"This was draw by thread l" <Endl ;}} void threadfunc2 (pvoid PARAM) {While (1) {sleep (10 ); out <"This was draw by thread 2" <Endl ;}} void threadfunc3 (pvoid PARAM) {While (1) {sleep (10 ); out <"This was draw by thread 3" <Endl ;}} void threadfunc4 (pvoid PARAM) {While (1) {sleep (10 ); out <"This was draw by thread 4" <Endl ;}int main () {char * pstr = "parameter passed successfully"; _ beginthread (threadfunc1, 0, pstr); _ beginthread (threadfunc2, 0, null); _ beginthread (threadfunc3, 0, null); _ beginthread (threadfunc4, 0, null); sleep (1000 ); out <"end"; return 0 ;}
Multithreading is required for other programs.