ҧ Threads Ẻ implements Runnable
:: ¹ҡѹ :: ѡѺ Threads
หน้า 1 จาก 1
ҧ Threads Ẻ implements Runnable
package threads;
public class runnable implements Runnable {
@Override
public void run() {
}
public static void main(String[] args) {
}
}
Re: ҧ Threads Ẻ implements Runnable
package threads;
public class runnable implements Runnable {
@Override
public void run() {
}
public static void main(String[] args) {
}
}
¡
[quote="Admin"]package threads;
public class runnable implements Runnable {
private String name;
@Override
public void run() {
for(int i=1;i
Ẻ extends Thread
package threads;
public class extendsThread extends Thread {
private String name;
@Override
public void run() {
for(int i=1;i<=20;i++)
System.out.println(name+" : "+i);
}
public extendsThread(String name) {
this.name = name;
}
public static void main(String[] args) {
// Thread t1 = new Thread(new extendsThread("A")); // Ẻ 1.
// new Thread(new extendsThread("B")).start(); // Ẻ 2.
// Ẻ new
new extendsThread("C").start();
new extendsThread("B").start();
new extendsThread("A").start();
}
}
public class extendsThread extends Thread {
private String name;
@Override
public void run() {
for(int i=1;i<=20;i++)
System.out.println(name+" : "+i);
}
public extendsThread(String name) {
this.name = name;
}
public static void main(String[] args) {
// Thread t1 = new Thread(new extendsThread("A")); // Ẻ 1.
// new Thread(new extendsThread("B")).start(); // Ẻ 2.
// Ẻ new
new extendsThread("C").start();
new extendsThread("B").start();
new extendsThread("A").start();
}
}
Re: ҧ Threads Ẻ implements Runnable
new extendsThread("C").start();
new extendsThread("B").start();
new extendsThread("A").start();
ѧࡵؤѹ return ͡
new extendsThread("B").start();
new extendsThread("A").start();
ѧࡵؤѹ return ͡
Admin พิมพ์ว่า:
Thread t1 = new extendsThread("C").start();
Thread t2 = new extendsThread("B").start();
Thread t3 =new extendsThread("A").start();
-------------------------------------------Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Type mismatch: cannot convert from void to Thread
Type mismatch: cannot convert from void to Thread
Type mismatch: cannot convert from void to Thread
at threads.extendsThread.main(extendsThread.java:28)
Similar topics
» implement Runnable ???? Extends Threads
» ??? implements Comparable ??Ѻ??????ѹ Sort ??
» t.join(); // ??????ͤ???觹?? Threads ?Т??ѹ t ??????稡??֧?????ҧ???
» ??? implements Comparable ??Ѻ??????ѹ Sort ??
» t.join(); // ??????ͤ???觹?? Threads ?Т??ѹ t ??????稡??֧?????ҧ???
:: ¹ҡѹ :: ѡѺ Threads
หน้า 1 จาก 1
Permissions in this forum:
คุณไม่สามารถพิมพ์ตอบ