Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Multi-Thread command line executor cause uncertain result  RSS feed

 
Zee Ho
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All, I have writen a Java program to execute the external program.
sth like execute "cat < abc.xml" and such java program will return same result as linux command.


I test the program use such way : give my program 64 same file and
let it execute them. In some of the machine the task 100% completed, while in some machine several task failed with exceptions as :

- 2005-10-12 [Thread-712] java.io.IOException: Stream closed
OR
- 2005-10-12 [Thread-878] java.io.IOException: Bad file descriptor
(I am still the file is not missing)

I know using thread is error-prone, but I can not figure out what mistake I have made. any suggestion on ehancing the program?

 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please CarefullyChooseOneForum for your questions. Don't post the same question to multiple forums. I've deleted the one in Java in General (Beginner), as this is not what I'd call "beginner" code.

So what's different about the machines where this fails? What OS are they running? Are they all the same?
 
Zee Ho
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No one is suse unix and another is redhat linux.

in redhat, seems 100% complete.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you running the Sun JVM on both, or is the failing one Kaffe or some other open-source VM?
 
Zee Ho
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I run on same Sun's java vm

As I can not find out a way to make it stable I changed my way to execute the external program

that I develop a .sh file which take 3 parameter as $1 < $2 > $3

then the way I run the arbitrary program become
1. obtain the program path for $1
2. write the input file to file system rather than manipulating the input/output stream through the Process class. $2 became the input file path
3. offer the destination file path for $3

then let the underlying OS execute the .sh became more stable than my previous solution

would like share this idea to ranchers if helpful
[ October 13, 2005: Message edited by: Zee Ho ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!