Running multiple threads
Running multiple threads
A thread is executed concurrently by creating it and starting it. The code to create two new Loop threads would be:
// Create Threads
Thread A = new Thread(new Loop());
Thread B = new Thread(new Loop());
// Start Threads
A.start();
B.start();
This program would be captured in our formal notation as:
main ® ( A || B || main’ )
Demo