Can someone explain to me if the following code should work. Its just a simple test with threads and Applets. Thread 1 prints date and time to Applet. Thread 2 prints date and time to console (am using Jbuilder) When I run this in Jbuilder there is no output displayed on the applet, but there date is updated on the console. If I put System.out.println()s on either side of repaint() they get printed in a loop, which says to me that repaint is being called but for some reason never gets as far as calling paint. Am i missing something fundamental or should this work?
hi Dermot In the code you have line that says, work.run(); is a problem because, 1. if we call run() method directly on a thread it doesn't start a thread but instead just results into a method call. That line should be - work.start() 2. now, that run() is in infinite loop and as its a method call it hogs the JVM due to which the Applet UI Thread never gets a chance to paint data on the applet screen even if it is generating that data by calling repaint() So, work.start() should do magic for you. Otherwise I don't see any problem. Regards Maulin
posted 16 years ago
Thanks Maulin, it works perfect
Put the moon back where you found it! We need it for tides and poetry and stuff. Like this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!