wood burning stoves*
The moose likes Java in General and the fly likes How to run a program in the background? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "How to run a program in the background?" Watch "How to run a program in the background?" New topic
Author

How to run a program in the background?

Michael Deng
Greenhorn

Joined: Dec 05, 2000
Posts: 12
Hi everyone,
Here is my code after I click place order.

//step 1, pre-process an order
order.PreProcess();//this step takes 1 second.
//step 2, send order to ERP;
order.SendToErp;//this step takes 15 seconds.
//step 3, display JSP
CallJsp();//this step takes 2 seconds.
As you can see, after I click the submit button, it will take me around 20 seconds to display the next page.
My question is: how to move step 2 into the background, so, step 3 don't need to wait the return of step 2.
thanks,
Michael
[ November 20, 2002: Message edited by: Michael Deng ]
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Do it in a separate Thread.


"JavaRanch, where the deer and the Certified play" - David O'Meara
Michael Deng
Greenhorn

Joined: Dec 05, 2000
Posts: 12
How to do it in a separate Thread?
Thanks!
Michael
Pete Lyons
Ranch Hand

Joined: Aug 18, 2002
Posts: 109
Michael,
Multi-threading is far too complicated to be explained in a discussion group post. You should find a good article or book that introduces threading and read that. Basically, you create a subclass of Thread (or a class that implements Runnable, which you pass into a Thread's constructor), and then call start(). Java Threads by Scott Oaks and Henry Wong (O'Reilly) is pretty good.
 
GeeCON Prague 2014
 
subject: How to run a program in the background?