Reputation: 1
How do you run two loops on the same batch file at once? for example this doesn't work:
@echo off
title matrix
mode 1000
color 0a
pause
goto A
goto B
:A
echo hi
goto A
:B
color a
Ping 1.1.1.1 -n 1 -w 7.5>nul
color b
Ping 1.1.1.1 -n 1 -w 7.5>nul
color c
Ping 1.1.1.1 -n 1 -w 7.5>nul
color d
Ping 1.1.1.1 -n 1 -w 7.5>nul
color e
Ping 1.1.1.1 -n 1 -w 7.5>nul
goto B
Upvotes: 0
Views: 531
Reputation: 56180
As already noted in the comments, there is no "mulitithreading" in a batchfile. But with a little logic, we can emulate it (here inside the same process).
@echo off
setlocal enabledelayedexpansion
set "colors=abcde"
:loop
timeout 1 >nul
set /a n=(n+1)%%8
call :a
if %n% equ 0 call :b
goto :loop
:A Main loop echoing
echo Hello World %random%
goto :eof
:B Secondary loop color changing
set /a col=(%col%+1)%%5
color %col%F
goto :eof
Upvotes: 1