In my program i have two methods:
public void methodA() { //gets called very often
//write something to file
}
public void methodB() {
//write something to file
}
methodA
gets called by the client very often, whereas methodB
gets only called from time to time. However, I need to make sure that whenever a client wants to call methodB
it can do so (after possible current execution of methodA
has finished). I tried to introduce a synchronized block with an locking object within each method however methodB
seems to starve, since methodA
gets called more often.
How can I solve this issue?