Olá tenho o seguinte codigo (em partes resumido):
public class Tarefa {
......
public Tarefa(int n) {
try {
this.numero = n;
this.tamanho = (int) (Math.pow(1.5,n) * 0.001);
} catch (Exception e) {
e.printStackTrace();
}
}
}
public class Trabalhador extends Thread
........
public Trabalhador(String id) {
try {
this.Id = id;
this.TarefaList = new LinkedBlockingQueue<Tarefa>();
this.start();
} catch (Exception e) {
e.printStackTrace();
}
}
public void run() {
try {
while (true) {
this.tarefa = this.tarefaList.take();
this.reduceTamanho(this.tarefa.getTamanho());
}
} catch (Exception e) {
e.printStackTrace();
}
}
public void novaTarefa(String tarefaId) {
// TODO Auto-generated method stub
try {
Tarefa t = new Tarefa(tarefaId);
tarefa.setID(tarefaId);
tarefaList.put(tarefa);
this.increaseTamanho(tarefa.getTamanho());
} catch (Exception e) {
e.printStackTrace();
}
}
public void reduceTamanho(int tamanho) {
this.trabalhadorTamnhoTotalTarefa -= tamanho;
}
public void increaseTamanho(int tamanho) {
this.trabalhadorTamnhoTotalTarefa += tamanho;
}
}
Os dois ultimos métodos não estão sendo executados, ou seja, a variavel trabalhadorTamnhoTotalTarefa não esta sendo incrementada ou decrementada corretamento. O que há de errado neste meu código?