Commit 4739de9a by Patryk Czarnik

Poprawki przykładów nt wątków

parent a01f61a9
......@@ -21,6 +21,7 @@ public class PuleWatkow {
System.out.println("Zaczynam zlecać...");
for(int i = 0; i < N; i++) {
pool.submit(zadanie);
// albo od razu lambdę: pool.submit(() -> System.out.println("a kuku"));
// pool.execute(zadanie);
// pool.schedule(zadanie, 2, TimeUnit.SECONDS);
try {
......@@ -29,7 +30,7 @@ public class PuleWatkow {
}
}
System.out.println("Zlecilem wykonanie");
System.out.println("Zleciłem wykonanie");
pool.shutdown();
//pool.shutdownNow();
......
......@@ -70,7 +70,7 @@ public class TworzenieWatkow {
Thread watek3b = new Thread(() -> {
System.out.println("wątek 3 b");
});
});
watek3b.start();
new Thread(() -> {
......
......@@ -12,7 +12,7 @@ public class AtomowyLicznik {
licznik.addAndGet(3); // +=
licznik.addAndGet(-3); // -=
// Number n = licznik; // OK
// Number n = licznik; // OK
// licznik.incrementAndGet();// ++x
// licznik.decrementAndGet();// --x
// licznik.getAndIncrement(); // x++
......
......@@ -34,7 +34,7 @@ public class Konto {
this.wlasciciel = wlasciciel;
}
public int getSaldo() {
public synchronized int getSaldo() {
return saldo;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment