|
-
July 30th, 1999, 01:00 AM
#1
threads
class WatchDog implements Runnable
{
public WatchDog(Runnable r, int ms)
{
Thread t = new Thread(r);
t.start();
try
{
Thread.sleep(ms);
}
catch (InterruptedException e)
{
}
t.stop();
}
}
public class KillThread
{
public static void main(String[] args)
{
Analysis a = new Analysis();
WatchDog w = new WatchDog(a, 1000);
}
}
class Analysis implements Runnable
{
public void run()
{
while (true)
{
System.out.println("analyze ");
}
}
}
i have got this code from a site when i was studying about threads. this gives a bunch of compile errors which i was unable to fix. would somebody mind fixing it for me and explain ??
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|