Java - Implementation of Thread using Thread
Java - Implementation of Thread using Thread
CODE
import java.util.Random;
public class Main
{
public static void main(String[] args) throws InterruptedException {
SampleThread t1 = new SampleThread(10);
t1.start();
t1.join();
System.out.println("Input: " + t1.Input);
System.out.println("Output: " + t1.Output);
}
}
class SampleThread extends Thread {
public int Input;
public int Output;
public SampleThread(int input) {
this.Input = input;
}
public void run() {
Output = Input + 10;
}
}
Comments
Post a Comment