China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-07 19:04
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Perfect Solution] Regarding the Problem of Multi-threaded start && Command Connection View 2,380 Replies 17
Floor 16 Posted 2007-09-05 22:44 ·  中国 广东 江门 新会区 电信
初级用户
Credits 30
Posts 15
Joined 2007-09-05 21:43
18-year member
UID 96658
Gender Male
Status Offline
I have seen it for a long time. After integrating the opinions from the upper floor, I finally tried to write it like this:

@echo off
set a=100
:loop
set /a a+=1
::start cmd /c &echo %a% >>%a%.txt
start cmd /c "ping -n 1 192.168.2.%a%&&echo 192.168.2.%a% >>ip.txt"
if "%a%"=="105" exit
goto :loop
Floor 17 Posted 2007-09-05 23:52 ·  中国 广东 江门 新会区 电信
初级用户
Credits 30
Posts 15
Joined 2007-09-05 21:43
18-year member
UID 96658
Gender Male
Status Offline
However, problems still occur when using multithreading. For example, if two threads complete output at the same time, data loss will occur. I tried starting 200 threads, and as a result, 113 were successfully written and the rest were lost. How should this be solved?
Floor 18 Posted 2008-03-12 17:21 ·  中国 浙江 嘉兴 海宁市 电信
中级用户
★★
Credits 360
Posts 216
Joined 2007-05-29 17:41
19-year member
UID 89677
Gender Male
Status Offline
start cmd /c & net send 10.20.8.214 "00">>11.txt
start cmd /c & net send 10.20.8.192 "00">>11.txt

Why can only send the first one, and the second one is gone?
Does it have to be PAUSE


The purpose of the above program is that when using NET send to send, it will consume a lot of time when encountering a failure
If it can be sent simultaneously, time can be saved!


[ Last edited by bd123456789 on 2008-3-12 at 08:53 PM ]
Forum Jump: