Unable to recognize the methods of "runnable"-

This is my simple code that implements runnable but I m getting the errors of methods and variable not found. Please reply soon;

import java.io.*;

import java.util.*;

import javax.servlet.*;

import javax.servlet.http.*;

public class Prime implements Runnable

{

long lastprime = 0;

Date lastprimeModified = new Date();

Thread searcher;

public void init()

{

searcher = new Thread(this).setPriority(Thread.MAX_PRIORITY);

start();

}

public void run()

{

long candidate = 1000000000000001L;

while(true)

{

if(isPrime(candidate))

{

lastprime = candidate;

lastprimeModified = new Date();

}

candidate += 2;

try

{

Thread.sleep(200);

}

catch(InterruptedException e)

{}

}

}

private static boolean isPrime(long candidate)

{

long sqrt = candidate;

for(long i=3;i<sqrt;++i)

{

if(candidate%i ==0)

return false;

}

return true;

}

public void doGet(HttpServletRequest req,HttpServletResponse res)

throws ServletException, IOException

{

res.setContentType("text/plain");

PrintWriter out = res.getWriter();

if(lastprime==0)

out.println("Search In Progress ... Please Wait....");

else

{

out.println("The last Prime Discovered was" + lastprime);

out.println("at" + lastprimeModified);

}

}

public void destroy()

{

searcher.stop();

}

}

Following are the errors:

Prime.java:16: cannot find symbol

symbol : variable MAX_PRIORITY

location: class Thread

searcher = new Thread(this).setPriority(Thread.MAX_PRIORITY).sta

rt();

^

Prime.java:16: cannot find symbol

symbol : constructor Thread(Prime)

location: class Thread

searcher = new Thread(this).setPriority(Thread.MAX_PRIORITY).sta

rt();

^

Prime.java:36: cannot find symbol

symbol : method sleep(int)

location: class Thread

Thread.sleep(200);

^

Prime.java:72: cannot find symbol

symbol : method stop()

location: class Thread

searcher.stop();

^

C:\Program Files\Java\jdk1.6.0\bin\Thread.java:42: cannot find symbol

symbol : method sleep(int)

location: class Thread

Thread.sleep(10000);

^

C:\Program Files\Java\jdk1.6.0\bin\Thread.java:9: cannot find symbol

symbol : constructor Thread(NewThread,java.lang.String)

location: class Thread

t = new Thread(this,name);

^

C:\Program Files\Java\jdk1.6.0\bin\Thread.java:11: cannot find symbol

symbol : method start()

location: class Thread

t.start();

^

C:\Program Files\Java\jdk1.6.0\bin\Thread.java:21: cannot find symbol

symbol : method sleep(int)

location: class Thread

Thread.sleep(1000);

^

8 errors>

[3015 byte] By [aniketh_parmara] at [2007-11-26 15:43:36]
# 1

The problem was with this code

searcher = new Thread(this);//.setPriority(Thread.MAX_PRIORITY);

searcher.setPriority(Thread.MAX_PRIORITY);

searcher.start();

Also dont forget that the stop method of a Thread is deprecated..

http://java.sun.com/docs/books/tutorial/essential/concurrency/threads.html

MeTitus

Me_Titusa at 2007-7-8 22:02:34 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...