File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes Why can't I use sleep method? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Why can Watch "Why can New topic

Why can't I use sleep method?

Yashnoo lyo
Ranch Hand

Joined: Feb 17, 2003
Posts: 152
I had created the Thread object but the program can't be compiled by javac!It says:Can't solve symbol.
My code is:
public class testRun implements Runnable{
String id;
Thread thread=new Thread();
public testRun(String str){
public void run(){
for(int i=0;i<1000;i++){
for(int j=1;j<100;j++);
}catch(InterruptedException e){}
System.out.println(id+"is running");
class testC{
public static void main(String args[]){
testRun dog=new testRun("hello");
testRun cat=new testRun("JavaBean");
Thread t1=new Thread(dog);
Thread t2=new Thread(cat);
Add I find when I use sleep method and it can output few of results.But it can output many results
when I don't use the sleep method.Why? Thank you!

When I face C# and Java I choose Java.
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

Can't *resolve* symbol.

Your error is: C:\ cannot resolve symbol
symbol : method sleep (double)

Your code:

Breaks down to Math.random() returns a double, multiply that by the result of casting 1000 to an integer. Which gives you a double. Which is why javac cannot resolve the method sleep(double).

And what does this have to do with JSP?
Yashnoo lyo
Ranch Hand

Joined: Feb 17, 2003
Posts: 152
Thank you very much for your help! I want to test the Thread class only and don't want to insert it to jsp.
I agree. Here's the link:
subject: Why can't I use sleep method?
It's not a secret anymore!