Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Random;
- public class Faelles {
- private int taeller;
- public Faelles() {
- super();
- taeller = 0;
- }
- public void tagerRandomTid(int max) {
- Random r = new Random();
- int nymax = Math.abs(r.nextInt()) % max + 1;
- int tal = 0;
- for (int i = 1; i < nymax; i++) {
- for(int j = 0; j < nymax; j++) {
- tal++;
- tal--;
- }
- }
- }
- public int getTaeller() {
- return taeller;
- }
- public synchronized void kritiskSection() {
- int temp = taeller;
- taeller = temp + 1;
- tagerRandomTid(99);
- }
- }
Add Comment
Please, Sign In to add comment