# Multithread applications

>> Sample Code: \rsxnt\sample\console\thread

RSXIDE

The switch -Zmt allows to create several threads with the C-Library function _beginthread(). Refer the EMX manuals.

Compile command:

        gcc -Zwin32 -Zmt thread.c

Multithread example:

    void mythread (void *param)
    {
        int i;

        for (i = 0; i < 1024; ++i) {
            putchar('+');
            fflush(stdout);
        }
    }

    int main()
    {
        int i;

        if (_beginthread(mythread, NULL, 8192, NULL) == -1) {
            puts("no thread");
            exit(1);
        }

        for (i = 0; i < 1024; ++i) {
            putchar('.');
            fflush(stdout);
        }

        return 0;
    }