File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Linux / UNIX and the fly likes how to get result from java when java thread is running in background Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "how to get result from java when java thread is running in background" Watch "how to get result from java when java thread is running in background" New topic
Author

how to get result from java when java thread is running in background

rama ilango
Greenhorn

Joined: Dec 11, 2008
Posts: 24
I will call java program by shell script.
This java start the thread and return the result to the shell script.
My problem is shell script is waiting upto stop the thread.
I want the result when thread is running in background.
please reply.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16019
    
  20

"result" and "running" are two mutually exclusive terms. The whole definition of "result" is what you get after it finishes running.

If you're actually looking for the success/failure of the attempt to launch a thread, that's different. However a Java thread runs in a JVM, and the JVM process itself doesn't complete until all of its internal threads (which may not correspond to OS threads) have terminated.

Which is all I can say without knowing more.


Customer surveys are for companies who didn't pay proper attention to begin with.
rama ilango
Greenhorn

Joined: Dec 11, 2008
Posts: 24
for example
this is my script file as shelltest.sh

output=`java test`
echo "$output";
echo "success";

when run this script, it run the test.java.
this java file call the thread.
So this script is completed, after stop the thread only.
But i want : when thread is running in background, the script file should print the success(It is in echo) and come out from sh.
reply me
Raf Szczypiorski
Ranch Hand

Joined: Aug 21, 2008
Posts: 383
If I understand correctly, you want to start a java process and return. If that's what you want:

java test &
echo Success

and that's it. & is a special bash character that tells it to invoke the command in a background process.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to get result from java when java thread is running in background