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
public class MainObjectLifeCycle { | |
public static void main(String[] args) { | |
LifeCycle lc1 = new LifeCycle (); | |
lc1.name="Kamila"; | |
lc1= new LifeCycle(); |
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
public class MainObjectLifeCycle { | |
public static void main(String[] args) { | |
LifeCycle lc1 = new LifeCycle (); | |
lc1.name="Kamila"; | |
lc1= new LifeCycle(); |
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
public class MainObjectLifeCycle { | |
public static void main(String[] args) { | |
//este primeiro pode cair no recolhimento do Garbage Collector, pois não está mais sendo acessível | |
LifeCycle lc1 = new LifeCycle (); | |
lc1.name="Kamila"; | |
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
public class MainObjectLifeCycle { | |
public static void main(String[] args) { | |
//aqui temos dois objetos criados | |
//o primeiro lc1 não é mais acessível pois feita outra referência a ele mais abaixo | |
//ele foi atribuído para a a segunda variável lc1 | |
LifeCycle lc1 = new LifeCycle (); | |
lc1.name="Kamila"; |
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
public class MainObjectLifeCycle { | |
public static void main(String[] args) { | |
//aqui temos dois objetos criados | |
//o primeiro lc1 não é mais acessível pois feita outra referência a ele mais abaixo | |
//ele foi atribuído para a a segunda variável lc1 | |
LifeCycle lc1 = new LifeCycle (); | |
lc1.name="Kamila"; |
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
public class MainObjectLifeCycle { | |
public static void main(String[] args) { | |
// | |
LifeCycle lc1 = new LifeCycle (); | |
//aqui temos um objeto referenciado, que é acessível, pois consegue utilizar os atributos da | |
//classe LifeCycle que foi instanciada | |
lc1.name="Kamila"; | |
System.out.println("objetos="+LifeCycle.counter); | |
System.out.println(lc1.name); |
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
public class MainObjectLifeCycle { | |
public static void main(String[] args) { | |
//com o comando new é possível criar novo objetos | |
new LifeCycle(); | |
System.out.println("objetos="+LifeCycle.counter); | |
} | |
} |
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
public class MainObjectLifeCycle { | |
public static void main(String[] args) { | |
//criou variavel de referencia first do tipo aluno ainda não foi criado um objeto | |
LifeCycle first; | |
System.out.println("objetos="+LifeCycle.counter); | |
} | |
} |
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
public class LifeCycle { | |
static int counter; | |
//criamos o atributo name | |
String name; | |
public LifeCycle(){ | |
// toda vez que o construtor LifeCycle é invocado é incrementado +1 no counter | |
counter++; | |
} | |
} |
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
const cluster = require('cluster'); | |
const http = require('http'); | |
const numCPUs = require('os').cpus().length; | |
if (cluster.isMaster) { | |
console.log(`Processo Master ${process.pid} está em execução`); | |
for (let i = 0; i < numCPUs; i++) { | |
cluster.fork(); | |
} |