Created
March 23, 2023 23:20
-
-
Save hdelei/93a03769f7d3be648328b48d717f9f65 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ClasseThread extends Thread{ | |
String descricaoClasse; | |
public ClasseThread(String descricao){ | |
descricaoClasse = descricao; | |
} | |
public void run(){ | |
int soma = 0; | |
for (int i = 0; i < 100; i++){ | |
soma += i; | |
System.out.println( descricaoClasse + ": somando os números de 1 a 100 é igual : " + soma); | |
} | |
} | |
} | |
public class ExemploThread { | |
public static void main(String[] args) { | |
//Criando uma nova thread dentro do prog... | |
ClasseThread ta = new ClasseThread("Classe 1"); | |
ClasseThread tb = new ClasseThread("Classe 2"); | |
tb.start(); | |
ta.start(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment