Let's say I have a thread:
Thread threadA = new Thread(() -> {
int i = doSomething();
});
I want to call another method that takes the int 'i' as a parameter, but doing that from threadA slows down the thread too much. How do I do this:
Thread threadA = new Thread(() -> {
int i = doSomething();
doSomethingElse(i);
});
but have the method 'doSomethingElse()' be executed on another thread (threadB), and if threadB is busy, wait until it's not and execute then?