BlockingQueue<Integer> multipliedNumbers = new PriorityBlockingQueue<Integer>();
Thread multiplicationThread = new Thread(new MultByN(exponentialNumbersOf, multipliedNumbers, 2));
multiplicationThread.start();
try {
multiplicationThread.join();
} catch (InterruptedException IntExcep) {
// TODO: handle exception
}
Thread consumerThread2 = new Thread(new Print(multipliedNumbers));
consumerThread2.start();
so this is in my main, as you cann see I start a multiplicationThread, and start it, and I tell the program to wait until the thread finishes, before starting the consumerThread, which sole function is to print the data of the blocking queue. But the consumerThread never starts
This is in my multiplicationThread
@Override
public void run() {
try {
System.out.println("Thread has started");
while(true) {
int numberToBeMultipliedByN = exponentialNumbers.take();
int multiplicatedNumber = numberToBeMultipliedByN*n;
multiplicationNumbers.add(numberToBeMultipliedByN);
if(!exponentialNumbers.contains(multiplicatedNumber))
multiplicationNumbers.add(multiplicatedNumber);
Thread.sleep(100);
}
} catch (InterruptedException e) {
}
}
so my output is:
Thread has started
but the printing never starts