Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class MainThread {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Scanner answer = new Scanner(System.in);
- System.out.println("Give me a single character: ");
- char h = answer.next().charAt(0);
- System.out.println("Give me another single character: ");
- char a = answer.next().charAt(0);
- MyThread t1 = new MyThread(h);
- MyThread t2 = new MyThread(a);
- t1.start(h);
- t2.start(a);
- answer.close();
- }
- import java.util.*;
- public class MyThread extends Thread{
- Scanner answer = new Scanner(System.in);
- public MyThread(char x) {
- // TODO Auto-generated constructor stub
- }
- public void Stored(char x){
- System.out.println("Type a single letter here: ");
- }
- //modified run method
- public void start(char x){
- for(int i = 0; i < 1000; i++){
- System.out.print(x);
- try {
- Thread.sleep(1);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- Thread.yield();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement