File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to run a program in the background?

 
Michael Deng
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8521
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do it in a separate Thread.
 
Michael Deng
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to do it in a separate Thread?
Thanks!
Michael
 
Pete Lyons
Ranch Hand
Posts: 109
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic