Olá sou novato em java e tenho uma dúvida o quanto ao estilo de programação, podemos dizer assim. tenho a seguinte situação:
public class Gerente {
BlockingQueue<Integer> answerList;
public Gerente(){
this.answerList = new LinkedBlockingQueue<Integer>();
}
}
public class Trabalhador {
BlockingQueue<Integer> answerList;
public Trabalhador(Gerente ger){
this.answerList = ger.answerList();
}
public void run() {
while (true) {
int i = this.answerList.take();
...
}
}
}
Somente gostaria da opinião de você se é interessante utilizar a lista bloqueante dessa maneira ou se seria mais interessante na classe Gerente eu fazer uma chamada de metodo para a classe Trabalhador, algo do tipo:
public class Gerente {
BlockingQueue<Integer> answerList;
public Gerente(){
this.answerList = new LinkedBlockingQueue<Integer>();
Trabalhador t = new Trabalhador();
}
t.addList(1443);
}
public class Trabalhador {
BlockingQueue<Integer> answerList;
public Trabalhador(){
this.answerList = new LinkedBlockingQueue<Integer>();
}
public void run() {
while (true) {
int i = this.answerList.take();
...
}
}
public void addList(int i) {
this.answerList.put(i);
}
Se alguem poder me auxiliar … AGRADEÇO