A
ash
Hello All,
I have a synchronized method that includes a for loop which basically
invoke some methods dynamically from other classes and then highlight
some text in a JTextArea then it waits for 1000 ms (this.wait(1000)).
The class that includes this synchronized method extends Object.
The problem is that when i press the button that invokes this method
everything in the GUI hangs until the method finishes.But every other
thing than the GUI works normally.
What is supposed to happen is that every thing works normally and
then the caller object sleeps for 1000 ms , wakes up and continue ....
---Code snippet begin --
for(Method m : algClass.getDeclaredMethods())
{
if(m.toString().endsWith("Do()"))
{
methodStack.push(m);
algViewArea.eraseAllHighLights();
algViewArea.highLightLine(((Algorithm)classLoadedObject).getCurrentLine());
m.invoke(classLoadedObject, (Object[]) null);
this.wait(1000);
}
}
--Code snipper End--
everything works fine except the following :
1) algViewArea.eraseAllHighLights();
2)
algViewArea.highLightLine(((Algorithm)classLoadedObject).getCurrentLine());
And in general the whole GUI hangs ...
What am i missing ?
Thanx in advance for your help
Ahmed Ashmawy
I have a synchronized method that includes a for loop which basically
invoke some methods dynamically from other classes and then highlight
some text in a JTextArea then it waits for 1000 ms (this.wait(1000)).
The class that includes this synchronized method extends Object.
The problem is that when i press the button that invokes this method
everything in the GUI hangs until the method finishes.But every other
thing than the GUI works normally.
What is supposed to happen is that every thing works normally and
then the caller object sleeps for 1000 ms , wakes up and continue ....
---Code snippet begin --
for(Method m : algClass.getDeclaredMethods())
{
if(m.toString().endsWith("Do()"))
{
methodStack.push(m);
algViewArea.eraseAllHighLights();
algViewArea.highLightLine(((Algorithm)classLoadedObject).getCurrentLine());
m.invoke(classLoadedObject, (Object[]) null);
this.wait(1000);
}
}
--Code snipper End--
everything works fine except the following :
1) algViewArea.eraseAllHighLights();
2)
algViewArea.highLightLine(((Algorithm)classLoadedObject).getCurrentLine());
And in general the whole GUI hangs ...
What am i missing ?
Thanx in advance for your help
Ahmed Ashmawy