@AtomicMethod private void smokeCigarette() { if (tobacco.get() == 1 && paper.get() == 1 && match.get() == 1) { tobacco.dec(); paper.dec(); match.dec(); resource.inc(); } else { resource.inc(); // probleem is dat deze dus rolled back wordt. retry(); } }
@AtomicMethod private void giveResource() { if (resource.get() == 0) { resource.inc(); } }