Stiahnite si zdrojovy kod zo 6. prednasky.
Uloha 1
Identifikujte a opravte chyby v nasledujucom kuse kodu (skuste si ho pustit, aj viackrat):
public class FunWithThreadsLive {
List<String> listString = new ArrayList<>();
public static void main(String[] params) throws InterruptedException {
FunWithThreadsLive f = new FunWithThreadsLive();
Random rand = new Random();
for (int i = 0; i <= 100; i++)
f.listString.add(String.valueOf(UUID.randomUUID()));
Thread threadOne = new Thread(() -> {
for (String s : f.listString)
System.out.println(s);
});
Thread threadTwo = new Thread(() -> {
for (int i = 0; i < 99; i++)
f.listString.remove(rand.nextInt(f.listString.size()));
});
threadTwo.start();
threadOne.start();
threadTwo.join();
threadOne.join();
}
Uloha 2
Vytvorte novy (dalsi view) pre triedu Steve v baliku mvc.
Tento view bude view pre CRUD operacie s triedou Steve v konzole (CLI), bude implementovat interface SteveView.
Bonus: aj v baliku mvp