Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Created by Пётр on 04.10.15.
- */
- public class Threads1 {
- public static MyThread t = new MyThread();
- static String message = "inside main ";
- public static void main(String a[]) throws Exception {
- t.start();
- for (int i = 0; i < 10; i++) {
- System.out.println(message + i);
- sleep();
- }
- }
- static class MyThread extends Thread {
- String message = "inside MyThread ";
- public void run() {
- for (int i = 0; i < 10; i++) {
- System.out.println(message + i);
- Solution.sleep();
- }
- }
- }
- public static void sleep() {
- try {
- Thread.sleep(10);
- } catch (InterruptedException e) {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement