0% found this document useful (0 votes)
20 views2 pages

Tecnologico Nacional de México Instituto Tecnológico de León

This document is a student assignment submission for a Systems Computing course at the Technological Institute of Leon in Mexico. The assignment asks the student to create 3 threads with identifiers that display values from a cycle. The student's code creates 3 Runnable objects that implement the Runnable interface, each with a different character identifier, and starts each one as a new Thread. Each thread iterates from 0 to 9, printing the iteration number and its character, and increments a static counter shared between all threads.

Uploaded by

Charlie Calvillo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views2 pages

Tecnologico Nacional de México Instituto Tecnológico de León

This document is a student assignment submission for a Systems Computing course at the Technological Institute of Leon in Mexico. The assignment asks the student to create 3 threads with identifiers that display values from a cycle. The student's code creates 3 Runnable objects that implement the Runnable interface, each with a different character identifier, and starts each one as a new Thread. Each thread iterates from 0 to 9, printing the iteration number and its character, and increments a static counter shared between all threads.

Uploaded by

Charlie Calvillo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

TECNOLOGICO NACIONAL DE

MÉXICO
Instituto Tecnológico de León
Carrera: Sistemas Computacionales

Materia: Taller de Administración

Tema: Tarea # 16 3 hilos con identificador mostrar valores de un ciclo

Alumno: Charlie Edson Serrano Calvillo

Maestro: ING Luis Eduardo Gutiérrez Ayala


11 de mayo del 2019

public class Hilos {


public static void main(String[] args) {
Lerolero app = new Lerolero('x');
Thread th = new Thread(app);
Lerolero app2 = new Lerolero('y');
Thread th2 = new Thread(app2);
Lerolero app3 = new Lerolero('z');
Thread th3 = new Thread(app3);
// th.setPriority(1);
th.start();
// th2.setPriority(5);
th2.start();
// th3.setPriority(10);
th3.start();
}
}
class Lerolero implements Runnable{

int ent;
char c;
static int saldo = 0;
public Lerolero(char c){
this.c = c;
}
@Override
public void run() {
for (; ent < 10; ent++) {
int sal = saldo;
System.out.println(ent + "" + c);
// try{
// Thread.sleep(250);
// }catch(Exception e){
// }
saldo = sal + 1;
// saldo++;
}
System.out.println(saldo);
}
}

You might also like