What is multithreading? |
Top Previous Next |
Multithreading is an environment where more than one "thread" of execution can take place at the same time. Without support for multithreading, or more than one "thread" of execution, the programmer will be forced to handle everything in one execution context. Windows is a multithreaded environment in that many simultanous things can take place at the same time: the email client program can receive an email at the same time as the user is using the spreadsheet program and maybe copying a file all at the same time.
In a VPL program without multithreading, only one thread of execution is automatically started by the RTCU system software:
PROGRAM test;
With multithreading, however, the VPL program can start additional threads of execution by declaring thread-blocks:
THREAD_BLOCK Piper;
PROGRAM test;
The output of the the multithreaded program above will therefore be:
Hello from main! Hello from piper!
**** OR:
Hello from piper! Hello from main!
The order of the execution cannot be predicted as the two threads execute concurrently.
Please continue reading the section Why use multithreading? |