Practice English Speaking&Listening with: Multithreading in Batch

Difficulty: 0

Welcome to the probably biggest problem in batch: Multithreading.

I have discovered this in cooperation with tDwtp, also called DDlol01.

This topic is a pretty easy one. It only requires a few commands.

The file in the background runs these loops at the same time.

As you see, there's an output of loop one, two and three.

This is possible by using the commands from the top.

'IF' checks if the file has been started by itself.

If so, it jumps to the label '%1' which is the first parameter.

'START' opens itself in the same CMD window ( /b )

with the parameters '2' and '3'. IF jumps to the loops '2' and '3'.

That is all for how to do it. Additionally, you need to know that the variables

that are used in each loop are not set in the others.

There is no actual communication between the threads.

To pass this by, you can create a file that contains the information to trade.

In this case, there is only the information that 'Timer' has finished.

The created file does not need to have a content, 'Output' just checks if the file exists.

If so, both make a pause. In case there are several pauses at the same

time, the one from the main file, so the one that

has been executed first, is first released.

Another useful trick is to have an output while the user gives an input (SET/P).

This is what the file looks like...

The ten seconds have finished and now there are two pauses at the same time.

If I press a key now... there is still the second pause.

Another key and the file is gone. So, that's it!

If you have any questions, post a comment at the bottom of the side and have fun batching!

The Description of Multithreading in Batch