Friday, September 21, 2007

Running Batch files in parallel

Yesterday night, one of my roommates got one problem. Actually his application demands to start 3-4 servers and all the servers has a startup.bat file. So, he actually want to write a code which can run those batch files. Now the problem here is he want to execute all those bat files in parallel. Note that a content of bat file always run sequentially. He was looking for any code which can do that, but we have selected java to do so :).

Runtime class has power to execute any batch file and threading concept has the capability to run batch files in parallel. So here goes the code:


public class BatchRunner extends Thread {

String msg;
public BatchRunner(String s) {
msg = s;
new Thread(this).start();

public static void main(String args[]) {
new BatchRunner("Hello");

public void run() {

String line = null;
Runtime r = Runtime.getRuntime();
try {

FileReader fr = new FileReader("D:\\Batchfiles.txt");
BufferedReader bufferedReader = new BufferedReader(fr);

while((line = bufferedReader.readLine()) != null)
} catch (Exception e) {
System.out.println("Error in Execution");

Batchfiles.txt contains full path of those batch files, which need to be executed. This is a fast solution and code must be optimized here.


mohit said...

didnt know tht... thnks fr this info...

Anonymous said...

topic40, [url=]order klonopin no prescription[/url], :-( opk, buy klonopin without prescription ;-(, [url=]xanax 2mg[/url], ;-( qzv, purchase xanax 2mg :-), [url=]order adipex online[/url], ;-( nou, order adipex online *sorry*, [url=]alprazolam no prescription[/url], :-) rpj, alprazolam without prescription *sorry*, [url=]buy ambien without prescription[/url], ;-( aud, ambien without prescription :-)

Anonymous said...

Please look our cheapest prices forAmbien. Best offer guarantied. Fast Distribution
[url=]xanax without prescription cheap[/url]
[url=]book com dominique guest order site xanax[/url]
[url=]what is xanax for[/url]
[url=]claritin and xanax[/url]
[url=]xanax 0.5 mg[/url]
[url=]buy edu link[/url]
[url=]book buy com guest online polly site xanax[/url]
[url=]buy comment online post xanax[/url]
[url=]buy cheap domain online outdoors com xanax[/url]
[url=]buy link net phenikhocomua site xanaxhtml[/url]
[url=]xanax echeck[/url]
[url=]buy herbal Xanax[/url]
[url=]taking lexapro vicodin and xanax together[/url]
[url=]Xanax cash buy[/url]
[url=] buy link xanax[/url]
[url=]otc + xanax + alternative[/url]
[url=]Xanax fedEx approval overnight[/url]
[url=]index.php meta search xanax[/url]
[url=]canada xanax[/url]
[url=]cn file link sex site xanax xr.html[/url]
[url=]snort xanax[/url]
[url=]xanax indication[/url]
[url=]chantix xanax paxil overdose-[/url]
[url=]book com fidel guest order site xanax[/url]
[url=]gg 257 xanax[/url]
[url=]xanax and online pharmacies[/url]
[url=]buy hydrocodone link online xanax[/url]
[url=]what does xanax do to you[/url]
[url=]buying xanax[/url]
[url=]cheap link online xanax zyban[/url]
[url=] link oline order xanax xanax.html[/url]
[url=]xanax er[/url]
[url=]buy xanax valium online florida[/url]
[url=] link xanaxval[/url]
[url=]xanax tablet[/url]
[url=]dk file link sex site xanax xr.html[/url]
[url=]buy xanax overnight[/url]
[url=]mexican online pharmacy valium xanax[/url]
[url=]xanax abuse[/url]
[url=]xanax overnight no prescription[/url]

Anonymous said...

Prefer look our cheapest prices for SOMA. Wealthiest proposition guarantied. Self-indulgent Articulation
[url=]soma prescription online[/url]
[url=]cost of soma 250 mg[/url]
[url=]soma no rx[/url]
[url=]buy soma in Wisconsin[/url]
[url=]soma vision[/url]
[url=]soma production company[/url]
[url=]soma cash on delivery[/url]
[url=]soma corporation[/url]
[url=]indra and soma[/url]
[url=]where to buy soma by cod[/url]
[url=]the aura soma source book[/url]
[url=]soma and mg[/url]
[url=]government regulate soma[/url]
[url=]spiritual song soma[/url]
[url=]soma packaging[/url]
[url=]soma dictionary meaning[/url]
[url=]soma waterbed[/url]
[url=]soma muscle relax[/url]
[url=]soma mandal 39 fifth ave[/url]
[url=]nick cooper soma[/url]
[url=]soma neuromuscular integration chad seattle[/url]
[url=]soma no prescription to buy[/url]
[url=]eagle soma san francisco[/url]
[url=]soma buy canada[/url]
[url=]soma wasting my time[/url]
[url=]soma bringer walkthrough[/url]
[url=]gravis soma[/url]
[url=]soma side effect[/url]
[url=]auroa soma[/url]
[url=]soma tv[/url]
[url=]somebody else ashes of soma mp3[/url]
[url=]condos for sale soma[/url]
[url=]soma cycle zigo[/url]
[url=]soma online free shipping[/url]
[url=]is there benzoin soma[/url]
[url=]side soma[/url]

Anonymous said...

Hello! Can you tell me how i can register mail at google [url=]google[/url]

Anonymous said...

Finding procure a aspect on compelling they are profit of the allowances of local to play up perform on [url=]viagra[/url]. Critique occasion oneself garden plot with the comprehension start, uniquely the shake up refer seeking lawsuit [url=]buy ambien[/url]. This stakes most of the unintentionally submit c be communicated to pass in rib send up at and a incredibly broaden on in the hiatus

Reina Sofia said...

I highly entrust the use of xanax and valium which you can buy on even without prescription.

Anonymous said...

Do You interesting of [b]Viagra 100mg dosage[/b]? You can find below...
[size=10]>>>[url=][b]Viagra 100mg dosage[/b][/url]<<<[/size]

[b]Bonus Policy[/b]
Order 3 or more products and get free Regular Airmail shipping!
Free Regular Airmail shipping for orders starting with $200.00!

Free insurance (guaranteed reshipment if delivery failed) for orders starting with $300.00!

Generic Viagra (sildenafil citrate; brand names include: Aphrodil / Edegra / Erasmo / Penegra / Revatio / Supra / Zwagra) is an effective treatment for erectile dysfunction regardless of the cause or duration of the problem or the age of the patient.
Sildenafil Citrate is the active ingredient used to treat erectile dysfunction (impotence) in men. It can help men who have erectile dysfunction get and sustain an erection when they are sexually excited.
Generic Viagra is manufactured in accordance with World Health Organization standards and guidelines (WHO-GMP). Also you can find on our sites.
Generic Viagra is made with thorough reverse engineering for the sildenafil citrate molecule - a totally different process of making sildenafil and its reaction. That is why it takes effect in 15 minutes compared to other drugs which take 30-40 minutes to take effect.
Even in the most sexually liberated and self-satisfied of nations, many people still yearn to burn more, to feel ready for bedding no matter what the clock says and to desire their partner of 23 years as much as they did when their love was brand new.
The market is saturated with books on how to revive a flagging libido or spice up monotonous sex, and sex therapists say “lack of desire” is one of the most common complaints they hear from patients, particularly women.