Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class EjemploHilo6 implements Runnable {
- private int priority;
- public EjemploHilo6(int priority) {
- this.priority = priority;
- }
- public void run() {
- Thread t = Thread.currentThread();
- t.setPriority(priority);
- for (int i = 0; i < 20; ++i) {
- System.out.println("Esto es otro hilo: " + t);
- }
- }
- public static void main(String []args) {
- ThreadGroup tg = new ThreadGroup("fumador");
- Thread eh6_1 = new Thread(tg, new EjemploHilo6(1), "Ejemplo hilo 6 1");
- Thread eh6_2 = new Thread(tg, new EjemploHilo6(10), "Ejemplo hilo 6 2");
- eh6_1.start();
- eh6_2.start();
- try {
- eh6_1.join();
- eh6_2.join();
- }
- catch (InterruptedException ie) {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment