I am try to form a multi thread in my program but its giving this error
"\Java1.java:87: cannot find symbol
symbol : class mythread2
location: class Multithreading
Thread mythread1; mythread2
^
\Java.java:88: mythread1 is already defined in Multithreading(java.lang.String)
mythread1 = new Thread(this);
^
\Java.java:89: cannot find symbol
symbol : variable mythread2
location: class Multithreading
mythread2 = new Thread(this);
^
\java.java:90: cannot find symbol
symbol : variable mythread2
location: class Multithreading
mythread2.start();"
this is the lines of code that is giving the error

class Animation implements Runnable {

    Thread mythread1; mythread2
    Animation (String name) {
        mythread1 = new Thread( this );
       mythread2 = new Thread( this );
        mythread1.start();
        mythread2.start();
    }
...

Can anyone please tell me if it is possible to form a multi thread with

(this)

statment because I think thats where I am going wrong and if it possible how do I do it. Thanks

Well what you have is a plain ol' syntax error, on your Line No 3:-

Thread mythread1; mythread2

If you want to declare two references on the same line, use a comma (',') to separate the references and not a semicolon (';'), the semicolon is used only to terminate the statement, For example the statements inside your constructor all end if a semicolon.

And regarding your query, I leave that explanation to the javadocs of the Thread class.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.