Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package threadspriority;
- public class ThreadsPriority {
- public static void main(String[] args) {
- SimpleThread sthread1 = new SimpleThread("Jeremy", "Lucas");
- SimpleThread sthread2 = new SimpleThread("Big", "giB");
- SimpleThread sthread3 = new SimpleThread("Gay", "isOkay");
- Thread thrd1 = new Thread(sthread1);
- Thread thrd2 = new Thread(sthread2);
- Thread thrd3 = new Thread(sthread3);
- thrd1.start();
- thrd2.start();
- thrd3.start();
- }
- }
- package threadspriority;
- public class SimpleThread implements Runnable {
- String s1, s2;
- public SimpleThread(String s1, String s2) {
- this.s1 = s1;
- this.s2 = s2;
- }
- public void print() {
- for (int i = 0; i < 5; i++) {
- System.out.println(this.s1);
- try{
- Thread.sleep(500);
- }catch(InterruptedException e){
- }
- System.out.println(this.s2);
- }
- }
- @Override
- public void run() {
- this.print();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement