Bonus task | Lesson 10 | Level 7

Level 7, Lesson 10
Available

"Hey, soldier!"

"Good day, Captain!"

"I've got awesome news for you. Here are some exercises to reinforce your skills. Do them every day and your skills will grow at an insane speed. They were created especially for IntelliJ IDEA."

9
Task
Java Core,  level 7,  lesson 10
unavailable
Shared list
1. Change the Solution class so that it becomes a list. (It must implement the java.util.List interface). 2. The Solution list should only work with Longs. 3. Use the original field. 4. The list will be used by threads, so you need to ensure that all the methods are synchronized.
9
Task
Java Core,  level 7,  lesson 10
unavailable
Comparable
Implement the Comparable interface in the Beach class. Beaches will be used by threads, so you need to ensure that all the methods are synchronized. Implement the compareTo method so that when two beaches are compared the method returns a positive number if the first beach is better or a nega
9
Task
Java Core,  level 7,  lesson 10
unavailable
Pharmacy
Implement the Runnable interface in the Pharmacy and Person classes. All threads should run until isStopped is true. Here's the logic for the Pharmacy class: drugController should make a random drug purchase (getRandomDrug) in a random amount (getRandomCount) and wait 300 ms. Here's the logic for th
9
Task
Java Core,  level 7,  lesson 10
unavailable
Synchronized methods
Set the synchronized modifier only on the methods that need it. The Solution object will be used by threads.
9
Task
Java Core,  level 7,  lesson 10
unavailable
Superfluous synchronization
The synchronized keyword significantly slows a program, so remove unnecessary synchronized statements in methods.
9
Task
Java Core,  level 7,  lesson 10
unavailable
Ironing
Back to the daily grind... Add one synchronized keyword to make diana and steve take turns ironing, since there's only one iron! Hint: Use class-level locking.
9
Task
Java Core,  level 7,  lesson 10
unavailable
ApplicationContext
The ApplicationContext class will be accessible by many threads. Be sure that no data is lost: think about which keyword to put and where.
9
Task
Java Core,  level 7,  lesson 10
unavailable
ATM
Figure out how the program works. During testing, the log was found to contain the following: ..... Deposit 100, account balance 1100 Deposit 100, account balance 1200 Spend 1000, account balance 100 Insufficient money ..... There's a bug: Money is lost when debiting an account. Find and fix the bug.
9
Task
Java Core,  level 7,  lesson 10
unavailable
Transactionality
Make the joinData method transactional, i.e. if it fails, then the data must not be changed. 1. Read 2 file names from the console. 2. Read from the files line by line. Read from the first file into allLines, from the second file — into linesForRemoval. In the joinData method: 3. If the allLines lis
9
Task
Java Core,  level 7,  lesson 10
unavailable
Let's count
1. Make it so that the result is calculated for all the array elements, WITHOUT using Thread.sleep in the main(String[] args) method. 2. Correct the synchronized block so that the values array is filled with 1s

"Those previous exercises were for rookies. I've added some more advanced bonus exercises for the old-timers. Just for veterans."

9
Task
Java Core,  level 7,  lesson 10
unavailable
CRUD
CrUD: Create, Update, Delete. The program runs with one of the following sets of arguments: -c name sex bd -u id name sex bd -d id -i id Argument values: name (String) sex ("m" or "f") bd (birth date in the following format: "04 15 1990") -c (adds a person with the specified arguments to the end of
9
Task
Java Core,  level 7,  lesson 10
unavailable
CRUD 2
Batch CrUD: multiple Creations, Updates, Deletions. The program runs with one of the following sets of arguments: -c name1 sex1 bd1 name2 sex2 bd2 ... -u id1 name1 sex1 bd1 id2 name2 sex2 bd2 ... -d id1 id2 id3 id4 ... -i id1 id2 id3 id4 ... Argument values: name (String) sex ("m" or "f") bd (birth
9
Task
Java Core,  level 7,  lesson 10
unavailable
Restaurant
1. Figure out what the program does. For some reason, the waiter isn't bringing the prepared dishes out to the tables :( 2. Fix the bug. Hint: it's one line
Comments(19)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Piotr WikarskiLevel 19 , Birmingham
27 October, 07:28
After fixing the bug in ATM task, the program works the same as before feixing it..
JosephLevel 19
24 October, 07:31
The CRUD task made me want to play baseball with my computer. It said I wasn't really adding the person in "-c" when I added them exactly the same way someone else did who got that right. Then it was saying I was increasing the list size with "-u" when I wasn't adding anything to the list in those blocks. After 23 attempts the only way I was able to pass was by using other people's code which sucks because I always try my best to do things on my own.
Almaz TemirkanovLevel 23 , Bishkek
17 September, 12:47
Restaurant use ................ add(dish) in class cook
Almaz TemirkanovLevel 23 , Bishkek
17 September, 07:18
#1 use hot key 1. alt+insert 2. ctrl+r
Weichen OuyangLevel 25 , San Jose
12 September, 02:45
The solution to "Restaurant" is too simple. However, the structure of the whole project is very enjoyable and challenging! I'm digesting it and wish to call it "my code" someday.
JohnLevel 20 , Kazan
18 August, 08:58
I didn't understand CRUD 2. We used synchronized block, but didn't use Threads.
IsenrafLevel 20 , Douala
13 August, 18:37
Good for those who arrive here :). Courage
EwertonLevel 30 , Belo Horizonte
3 July, 17:59
I liked the Pharmacy one :)
HenkLevel 19 , Pretoria
1 June, 13:41
I just sucked with that restaurant task, cannot understand what the concurrent thread meant, also how to put prepared dished that the cook had finished somewhere in that strange variable......
Darko JakimovskiLevel 18 , Kriva Palanka
3 June, 07:12
I'm doing it now :D Did you manage to finish it?
HenkLevel 19 , Pretoria
3 June, 07:36
Nope, cannot even understand the syntax used in some of the code... i.e. concurrent thread will come back to it in 2026, not in the mood to sit with such an annoying confusing task for a whole day to try and trace all the threads, it's a nightmare. Even if people told me what needs to be done, I cannot figure out how to put it in the queue........made me feel REAL dumb, this one
Darko JakimovskiLevel 18 , Kriva Palanka
3 June, 07:39
LoL. feeling dumb on a daily basis is a part of the learning process I guess :D Happens to me A LOT! I'll tell you if I manage to finish it myself.
Darko JakimovskiLevel 18 , Kriva Palanka
3 June, 08:06
So, I just added a method to the manager class so that when a cook (added a line in the Cook class) is done preparing the Dish it gets added to Managers dishQueue. It passed :)
HenkLevel 19 , Pretoria
3 June, 08:22
I simply don't know how to link them all together and do that ?
Nicolas HuetLevel 37 , Provins
3 June, 13:44
When they say it's only one line, it's true! I was looking at this monster for a while, reading all of this, and at one time I figured it out, that was so "simple" I was sure that wasn't that! But it was, just one very simple line to add somewhere. No need to understand concurrentlinkedlist or everything. Just follow the logical path of the order and check if everything seems to be created and if after that they are put in the right place for being used later. Good luck!
HenkLevel 19 , Pretoria
5 June, 06:22
Thanks to Darko, I got it to work. Yeah, I'm trying (for current career opportunity in the same company) to get through it too fast, so don't want to spend hours tracing programs just to fix 1 line, but I guess there's no way with tasks from hereon forward to avoid this. It's going to become much bigger, e.g. days per problem. Looking forward to it.....not......LOL!
Ed MaphisLevel 20 , Painesville
15 June, 22:42
Ah Oh!!! It passes, but you are serving uncooked meals !!
RamilyaLevel 20 , SPb
28 May, 10:55
Over 1000 again!
Darko JakimovskiLevel 18 , Kriva Palanka
2 June, 09:16
I'm like 2K, knee deep in dark matter