0

New issue came up for me recently. I often must run simillar tasks and I would like to make my life easier.

Basicaly after choosing argument i always run one exe file with this argument and after that (these should work in the same time) I run bat file (with argument too).

After finishing I make some copies of generated files and move them to particular directories (all i based on argument sent while executing). Then all operations are reapeted many times.

Doing it manually is waist of time in my opinion.

Could you recommend any approach that would handle multithreading while working with files and directories?

tshepang
  • 12,111
  • 21
  • 91
  • 136
Lormitto
  • 477
  • 2
  • 7
  • 19

1 Answers1

-1

Usually you want to avoid excessive parallelism when accessing a shared resource. As I understand it what you do there is not CPU- but I/O-bound, therefore running more in parallel just increases congestion.

Furthermore, you cannot do multithreading in batch files – the langauge simply does not have the concept of threads. You can run multiple processes in parallel by launching them via start, but you would have to keep track of the dependencies yourself as well as make sure that you don't run too many simultaneously.

Joey
  • 344,408
  • 85
  • 689
  • 683
  • Are you really sure that Batch files (The ones that run in CMD.exe on Windows) cannot be multithreaded? Asking because there are several results stating that it works by using the `start` – Pranav Jituri Jul 07 '15 at 17:40
  • 1
    @Pranav: Yes, I'm very sure that multithreading is impossible in batch files. You have absolutely no way of starting your own threads at all. You can do multiprocessing by starting multiple processes (go figure). I have [another answer](http://stackoverflow.com/a/676667/73070) where I implemented just that. – Joey Jul 08 '15 at 08:10