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:

import java.io.BufferedReader;
import java.io.FileReader;

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)
{
r.exec(line);
}
} 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.

8 comments:

mohit said...

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

Anonymous said...

topic40, [url=http://www.chop.edu/forum/user/profile/8207.page]order klonopin no prescription[/url], :-( opk, http://www.chop.edu/forum/user/profile/8207.page buy klonopin without prescription ;-(, [url=http://www.chop.edu/forum/user/profile/8208.page]xanax 2mg[/url], ;-( qzv, http://www.chop.edu/forum/user/profile/8208.page purchase xanax 2mg :-), [url=http://forum.cprs.ca/default.aspx?g=posts&m=6]order adipex online[/url], ;-( nou, http://forum.cprs.ca/default.aspx?g=posts&m=6 order adipex online *sorry*, [url=http://forum.cprs.ca/default.aspx?g=posts&m=7]alprazolam no prescription[/url], :-) rpj, http://forum.cprs.ca/default.aspx?g=posts&m=7 alprazolam without prescription *sorry*, [url=http://forum.cprs.ca/default.aspx?g=posts&m=8]buy ambien without prescription[/url], ;-( aud, http://forum.cprs.ca/default.aspx?g=posts&m=8 ambien without prescription :-)

Anonymous said...

Hello!
Please look our cheapest prices forAmbien. Best offer guarantied. Fast Distribution
[url=http://www.testriffic.com/user/MygdsAnge/]xanax without prescription cheap[/url]
[url=http://www.testriffic.com/user/KbmxiZucn/]book com dominique guest order site xanax[/url]
[url=http://www.testriffic.com/user/VyrklEzkn/]what is xanax for[/url]
[url=http://www.testriffic.com/user/BkrgjYqpj/]claritin and xanax[/url]
[url=http://www.testriffic.com/user/KszihLcyc/]xanax 0.5 mg[/url]
[url=http://www.testriffic.com/user/AhtonVztu/]buy edu link xanax.ca.tf[/url]
[url=http://www.testriffic.com/user/KspnhVfvt/]book buy com guest online polly site xanax[/url]
[url=http://www.testriffic.com/user/CeyhuYjkp/]buy comment online post xanax[/url]
[url=http://www.testriffic.com/user/UwfwzMprd/]buy cheap domain online outdoors com xanax[/url]
[url=http://www.testriffic.com/user/HjlksDftc/]buy link net phenikhocomua site xanaxhtml[/url]
[url=http://www.testriffic.com/user/BfbixOxhp/]xanax echeck[/url]
[url=http://www.testriffic.com/user/MeadqOwto/]buy herbal Xanax[/url]
[url=http://www.testriffic.com/user/BhjhdKnvb/]taking lexapro vicodin and xanax together[/url]
[url=http://www.testriffic.com/user/RgdroFimf/]Xanax cash buy[/url]
[url=http://www.testriffic.com/user/XjpemTjci/]advertisersworld.com buy link xanax[/url]
[url=http://www.testriffic.com/user/JzcxbVahh/]otc + xanax + alternative[/url]
[url=http://www.testriffic.com/user/UvmijQgom/]Xanax fedEx approval overnight[/url]
[url=http://www.testriffic.com/user/YwaaiQskb/]index.php meta search xanax[/url]
[url=http://www.testriffic.com/user/GembzCewv/]canada xanax[/url]
[url=http://www.testriffic.com/user/ZipedXkxc/]cn file link sex site xanax xanaxonline.blog.expedia.fr xr.html[/url]
[url=http://www.testriffic.com/user/AkalvVbpx/]snort xanax[/url]
[url=http://www.testriffic.com/user/ZclsrHhsq/]xanax indication[/url]
[url=http://www.testriffic.com/user/MnxdkHsuc/]chantix xanax paxil overdose-[/url]
[url=http://www.testriffic.com/user/FmxccHnbx/]book com fidel guest order site xanax[/url]
[url=http://www.testriffic.com/user/ClbtzMfvt/]gg 257 xanax[/url]
[url=http://www.testriffic.com/user/EyfsnEdby/]xanax and online pharmacies[/url]
[url=http://www.testriffic.com/user/CkcibDkzb/]buy eteamz.active.com hydrocodone link online xanax[/url]
[url=http://www.testriffic.com/user/BespfUtkg/]what does xanax do to you[/url]
[url=http://www.testriffic.com/user/HzdkbAjjb/]buying xanax[/url]
[url=http://www.testriffic.com/user/YmrloEhzg/]cheap eteamz.active.com link online xanax zyban[/url]
[url=http://www.testriffic.com/user/ZhxdqHvxu/]dmoz.tzo.net link oline order xanax xanax.html[/url]
[url=http://www.testriffic.com/user/ZzzmzSnlg/]xanax er[/url]
[url=http://www.testriffic.com/user/LplbaRqrg/]buy xanax valium online florida[/url]
[url=http://www.testriffic.com/user/OnxenGuyq/]20six.nl link xanaxval[/url]
[url=http://www.testriffic.com/user/YcajnNhcq/]xanax tablet[/url]
[url=http://www.testriffic.com/user/ZawmbHifp/]dk file link sex site xanax xanaxonline.blog.expedia.fr xr.html[/url]
[url=http://www.testriffic.com/user/AlfmiYmbd/]buy xanax overnight[/url]
[url=http://www.testriffic.com/user/LjpqqBezy/]mexican online pharmacy valium xanax[/url]
[url=http://www.testriffic.com/user/TxufjSauf/]xanax abuse[/url]
[url=http://www.testriffic.com/user/UztbrSuah/]xanax overnight no prescription[/url]

Anonymous said...

Hello!
Prefer look our cheapest prices for SOMA. Wealthiest proposition guarantied. Self-indulgent Articulation
[url=http://vmtoolkit.com/members/Zoloft+and+xanax.aspx]soma prescription online[/url]
[url=http://vmtoolkit.com/members/Paxil+and+xanax+interaction.aspx]cost of soma 250 mg[/url]
[url=http://vmtoolkit.com/members/Soma+fab+smoothie+bicycle+review.aspx]soma no rx[/url]
[url=http://vmtoolkit.com/members/Soma+shipped+cod.aspx]buy soma in Wisconsin[/url]
[url=http://vmtoolkit.com/members/The+rose+at+soma.aspx]soma vision[/url]
[url=http://vmtoolkit.com/members/Aura+soma+usa.aspx]soma production company[/url]
[url=http://vmtoolkit.com/members/Soma+bringer+translation.aspx]soma cash on delivery[/url]
[url=http://vmtoolkit.com/members/Pronstar+soma.aspx]soma corporation[/url]
[url=http://vmtoolkit.com/members/Orca+dive+club+soma+bay.aspx]indra and soma[/url]
[url=http://vmtoolkit.com/members/Why+does+soma+give+me+energy.aspx]where to buy soma by cod[/url]
[url=http://vmtoolkit.com/members/Soma+marijuana+and+jagermeister.aspx]the aura soma source book[/url]
[url=http://vmtoolkit.com/members/Soma+addiction.aspx]soma and mg[/url]
[url=http://vmtoolkit.com/members/Timbuk2+soma.aspx]government regulate soma[/url]
[url=http://vmtoolkit.com/members/History+of+soma+drug.aspx]spiritual song soma[/url]
[url=http://vmtoolkit.com/members/Buy+fast+online+private+soma.aspx]soma packaging[/url]
[url=http://vmtoolkit.com/members/Soma+tablets.aspx]soma dictionary meaning[/url]
[url=http://vmtoolkit.com/members/Soma+bringer+follow.aspx]soma waterbed[/url]
[url=http://vmtoolkit.com/members/Death+from+soma+overdose.aspx]soma muscle relax[/url]
[url=http://vmtoolkit.com/members/Q+buy+soma+online.aspx]soma mandal 39 fifth ave[/url]
[url=http://vmtoolkit.com/members/Soma+fit+massage.aspx]nick cooper soma[/url]
[url=http://vmtoolkit.com/members/Soma+versus+flexeril.aspx]soma neuromuscular integration chad seattle[/url]
[url=http://vmtoolkit.com/members/Soma+crystal+bottle.aspx]soma no prescription to buy[/url]
[url=http://vmtoolkit.com/members/Soma+stop.aspx]eagle soma san francisco[/url]
[url=http://vmtoolkit.com/members/Drugtests+soma.aspx]soma buy canada[/url]
[url=http://vmtoolkit.com/members/Soma+salon+sudbury+ma.aspx]soma wasting my time[/url]
[url=http://vmtoolkit.com/members/Anti+soma.aspx]soma bringer walkthrough[/url]
[url=http://vmtoolkit.com/members/Soma+drug+tests.aspx]gravis soma[/url]
[url=http://vmtoolkit.com/members/Soma+carisoprodol+site.aspx]soma side effect[/url]
[url=http://vmtoolkit.com/members/Soma+stores.aspx]auroa soma[/url]
[url=http://vmtoolkit.com/members/Information+on+soma+the+moon+god.aspx]soma tv[/url]
[url=http://vmtoolkit.com/members/Soma+mail+medication.aspx]somebody else ashes of soma mp3[/url]
[url=http://vmtoolkit.com/members/Soma+fury.aspx]condos for sale soma[/url]
[url=http://vmtoolkit.com/members/L-o+soma+hotel+inc+sanfrancisco+ca.aspx]soma cycle zigo[/url]
[url=http://vmtoolkit.com/members/Soma+intimites.aspx]soma online free shipping[/url]
[url=http://vmtoolkit.com/members/Soma+puzzle+on+a+string.aspx]is there benzoin soma[/url]
[url=http://vmtoolkit.com/members/Soma+food+pantry+los+angeles.aspx]side soma[/url]

Anonymous said...

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

Anonymous said...

Finding procure a aspect on compelling they are profit of the allowances of local to play up perform on [url=http://onlineviagrapill.com]viagra[/url]. Critique occasion oneself garden plot with the comprehension start, uniquely the shake up refer seeking lawsuit [url=http://ambiendrug.com]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 www.medsheaven.com even without prescription.

Anonymous said...

Do You interesting of [b]Viagra 100mg dosage[/b]? You can find below...
[size=10]>>>[url=http://listita.info/go.php?sid=1][b]Viagra 100mg dosage[/b][/url]<<<[/size]

[URL=http://imgwebsearch.com/30269/link/buy%20viagra/1_valentine3.html][IMG]http://imgwebsearch.com/30269/img0/buy%20viagra/1_valentine3.png[/IMG][/URL]
[URL=http://imgwebsearch.com/30269/link/buy%20viagra/3_headsex1.html][IMG]http://imgwebsearch.com/30269/img0/buy%20viagra/3_headsex1.png[/IMG][/URL]
[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!
[b]Description[/b]

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.
[b][/b]
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.