public class Test implements Runnable { int id; Test(int id) { this.id = id; } public static void main(String[] args) throws InterruptedException { Thread thread1 = new Thread(new Test(1)); Thread thread2 = new Thread(new Test(2)); thread1.run(); thread2.start(); System.out.print("main"); } public void run() { System.out.print(id); } }
int id;
Test(int id) {
this.id = id;
}
public static void main(String[] args) throws InterruptedException {
Thread thread1 = new Thread(new Test(1));
Thread thread2 = new Thread(new Test(2));
thread1.run();
thread2.start();
System.out.print("main");
public void run() {
System.out.print(id);
Oracle Certified Professional Java Programmer
Access: Public Instant Grading
Jobilize.com uses cookies to ensure that you get the best experience. By continuing to use Jobilize.com web-site, you agree to the Terms of Use.