9
Задача
Java Core, ниво, урок
Synchronized notes
1. The Note class will be used by threads. So be sure that attempts to access the notes list lock notes, not this
2. Calls to System.out.println must not be synchronized, i.e. must not be in the synchronized block
5
Задача
Java Core, ниво, урок
Synchronized notes: part 2
The Note class will be used by threads. So be sure to synchronize all methods.
9
Задача
Java Core, ниво, урок
Time in the garden
1. Create a public void addFruit(int index, String fruit) method that adds the fruit parameter to the fruits list at position index.
2. Create a public void removeFruit(int index) method that removes the element at position index from fruits.
3. Create a public void addVegetable(int index, String ve
9
Задача
Java Core, ниво, урок
Synchronized president
We meet the singleton pattern again in synchronization in a static block.
Create a synchronized block inside a static block inside the OurPresident class.
Inside the synchronized block, initialize president.
5
Задача
Java Core, ниво, урок
IMF
Singleton pattern: synchronization in a method.
The IMF class is the International Monetary Fund.
Create a synchronized block inside the getFund method.
Inside the synchronized block, initialize imf so that the getFund method always returns the same object.