Home arrow static arrow Java Programming [Archive] - Thread problem
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - Thread problem
This topic has 5 replies on 1 page.

Posts:245
Registered: 11/3/02
Thread problem  
Aug 8, 2004 4:56 PM



 
Hello,

I have a little problem...

I have a network client that connects to a server.

The client has a window that is created when it starts but is set to visible false. When the client then receives a special message through the network thread, it should set the window to visible true.

The problem is that when the network thread sets the window to visible, the window is very sluggish and slow. If instead the window is set to visible true through the main() method of the program as the client starts it works perfect.

Enlight me...
 

Posts:8,813
Registered: 10/4/00
Re: Thread problem  
Aug 8, 2004 5:06 PM (reply 1 of 5)



 
My guess would be that the network io is blocking every so often and not allowing the repaint to complete. You simply don't see this blocking when the window is already painted. This is just a guess.
 

Posts:245
Registered: 11/3/02
Re: Thread problem  
Aug 9, 2004 1:16 AM (reply 2 of 5)



 
No....

The window is constantly repainted. It happens so often that its very easy to see when its slow and fast. It is added text into the window.

When adding something into the window and repainting it, and the window was set visible true through the network parsing, it takes like 100 ms.

When adding something and the window was set visible true in the main() method, it takes 0 ms.
 

Posts:2,909
Registered: 13.8.2003
Re: Thread problem  
Aug 9, 2004 1:37 AM (reply 3 of 5)



 
Show some relevant pieces of code (remember to use the formatting tags).
 

Posts:245
Registered: 11/3/02
Re: Thread problem  
Aug 9, 2004 12:23 PM (reply 4 of 5)



 
I can give pseudo code.

main(){    create a Frame    frame.setVisible(false);     create networking    start neworking thread and listen for packets} class Frame{    JTextPane tpane;     public void test(){        write a large amount of text into the textpane        calculate the time in milliseconds it took to perform it.    } } class Networking extends thread{    public void run(){        read packet        if packet == open window{            main.frame.setVisible(false)        }    }}


The thing is, by setting the frame to visible true with the networking thread, it makes the frame very slow.
The test method, has a difference of more than 1000 ms to write a bunch of text, and its not much text, just a few lines.

If instead the frame is set to visible true in the main() method, it works A LOT faster.
 

Posts:245
Registered: 11/3/02
Re: Thread problem  
Aug 9, 2004 2:03 PM (reply 5 of 5)



 
Actually...

The problem does not seem to be with the networking thread at all.

If I minimize the window to the system bar, then click on it to open it again, it goes with full speed.

It is just slow when it is set to visible first time...
 
This topic has 5 replies on 1 page.