aspose file tools*
The moose likes Applets and the fly likes Applet hangs while executing a Stored procedure. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "Applet hangs while executing a Stored procedure." Watch "Applet hangs while executing a Stored procedure." New topic
Author

Applet hangs while executing a Stored procedure.

Gemini Pai
Greenhorn

Joined: Apr 20, 2009
Posts: 5
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.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41797
    
  62
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.


Ping & DNS - my free Android networking tools app
Gemini Pai
Greenhorn

Joined: Apr 20, 2009
Posts: 5
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
Marshal

Joined: Mar 22, 2005
Posts: 41797
    
  62
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

Joined: Apr 20, 2009
Posts: 5
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
Marshal

Joined: Mar 22, 2005
Posts: 41797
    
  62
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

Joined: Apr 20, 2009
Posts: 5
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
Marshal

Joined: Mar 22, 2005
Posts: 41797
    
  62
That's what Thread.join does - wait until thread execution terminates. What do you hope to achieve with that statement?
Gemini Pai
Greenhorn

Joined: Apr 20, 2009
Posts: 5
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
Marshal

Joined: Mar 22, 2005
Posts: 41797
    
  62
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?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Applet hangs while executing a Stored procedure.