package workhome; public class ThreadPriority { public static void main(String[] args) { MyThread a= new MyThread("S"); System.out.println(a.getPriority()); a.setPriority(10); MyThread b=new MyThread("B"); b.setPriority(1); a.start(); b.start(); } } class MyThread extends Thread{ private String name; public MyThread(String name) { this.name=name; } public void run() { System.out.println(name); } }
package workhome; public class Runnable2 { public static void main(String[] args) { /* new Thread(new Runnable() { public void run() { for(int i=0;i<10;i++) { System.out.println(i); } } }).start(); */ new Thread() { public void run() { for(int i=0;i<100;i++) { System.out.println(i); } } }.start(); } }
package workhome; public class Runnable1 { public static void main(String[] args) { Runnable r=new Dog(); new Thread(r).start(); } } class Animal{ private String name; public String getName() { return name; } public void setName(String anme) { this.name=name; } } //Dog class Dog extends Animal implements Runnable{ public void eat() { System.out.println("like bone!"); } public void run() { eat(); } }