• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Applet hangs while executing a Stored procedure.

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Main thread of my applet is executing a Stored procedure. A child thread is running simultaneously trying to show status of the procedure execution.

But since the procedure is very expensive applet completely hangs (Blanks out..) and hence the status text area constructed by child thread is not getting rendered untill the procedure execution is completed and control returns to the applet.

Is there any way to avoid applet getting hanged in this situation..any help in this regard will be great.
Thanks in advance.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you starting a new thread to execute the DB call? It sounds as if you're running it from within the event handler thread -maybe in an action listener- which is a big No-No for Java GUIs.
 
Gemini Pai
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Currently yes its running in the same thread..But I have tried it with different thread as well...Even that was of no use..I have even tried rendering the status message using internal pane and pop up..but since the whole applet is blanked out none of these were usefull..
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Even that was of no use..


What does that mean? What -exactly- did you do, and what happened?

Please read the private message I sent you; you can find it by clicking on the "My Private Messages" link at the top of the page.
 
Gemini Pai
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As mentioned in my initial posting..I am tryig to run a applet which has to execute a Stored procedure and simultaneously show a status message.
As specified by you i have tried executing the Procedure in different thread. but even that did not stop applet from hanging. Due to which the status message constructed is not getting rendered while executing the procedure.

Is there any solution to avoid applet hanging during procedure execution..??
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, by starting a new thread. Maybe something doesn't quite work right in your code; if you post it we can take a look at it.
 
Gemini Pai
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please find the breif code below..

public class SetUp extends JFrame implements ActionListener,
Runnable {

public static void main(String arg[]) {
//Renders the initial screen..
}

public void actionPerformed(ActionEvent ae) {
if (ae.getSource() == "Execute") {
processCompMig();
}
}

private void processCompMig() {
Thread t = new Thread(this);
t.start();
//Executes the Procedure
t.join();
}

public void run() {
Thread.sleep(1000);
//Constructs text area to display procedure progress
}

}


while executing the method processCompMig() line 3, applet hangs. Even though run() method is getting executed, changes made are not reflected in the applet until the execution returns back to line 4 of processCompMig() method.

I have also tried executing the applet with below given changes

private void processCompMig() {
Thread t1 = new Thread(this,"ExecuteProcedure");
Thread t2 = new Thread(this,"DisplayProgress");
t1.start();
t2.start();

t1.join();
t2.join();
}

public void run() {
string threadName = Thread.getCurrentThread().getName();
if("ExecuteProcedure".equals(threadName)){
//execute Stored Procedure
}
else if(("DisplayProgress".equals(threadName)){
Thread.sleep(1000);
//Constructs text area to display procedure progress
}
}

Even this code did not have any impact while running the applet. It hanged during executing the procedure even in this case.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's what Thread.join does - wait until thread execution terminates. What do you hope to achieve with that statement?
 
Gemini Pai
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes I do understand what Thread.join is doing..but in the mean time applet hangs. Is there any way to avoid applet hanging such that I can view the applet...
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm confused - if you know what Thread.join does, and you wish to avoid the consequences of using it, then why *are* you using it?
 
reply
    Bookmark Topic Watch Topic
  • New Topic