Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package thread;
- public class Main {
- public static class MyThread implements Runnable
- {
- public void run()
- {
- for(int i=0; i<10; i++)
- {
- String s = Thread.currentThread().getName();
- System.out.println(s);
- try
- {
- Thread.sleep(50);
- }
- catch(Exception e)
- {
- }
- }
- }
- }
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Thread t1 = new Thread(new MyThread(), "Ping");
- Thread t2 = new Thread(new MyThread(), "Pong");
- t1.setPriority(Thread.MAX_PRIORITY);
- t2.setPriority(Thread.MIN_PRIORITY);
- t1.start();
- t2.start();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement