Hello.
And this week, we're going to review tasks for multithreaded topic.
Now you have enough knowledge to deal with them and even more by this moment, we've learned so many
things that you can solve the same tasks with multiple ways.
For example, you can solve synchronization task with synchronized Massud, synchronized Bloks Locks
or Synchronizer.
And let's review tasks first.
And after that I will tell you where you can find solution for these tasks in order.
You could check a solution later.
So in this file, you can find all home tasks that I recommend to implement to make sure you have enough
skills in most certain programming.
We are going to start from the super simple and gradually come to more complex tasks.
You can find the reference to this file in attachments to the lesson that's reviewed these tasks together,
and I will give my comments as we go.
The first task is simple one.
And just to practice your skills in creating stress in different ways and being able to interrupt threats,
it is recommended to create and start a threat in four different ways by implementing runnable interface,
by extending from STREAT class, bypassing the function to constructor of the class and bypassing the
master reference during the threat objects instantiation.
All of these ways were revealed in this course, so don't hesitate to navigate between the lessons to
find the answer to this question.
The next task is a little bit more complex than the first one, but still, I'm sure it will be easy
for you to implement.
You need to create some type that will spam messages with a specified interval of time.
And also you need to implement logic of threat interruption after enter key press.
I can give a hint you're here.
You can try to implement this logic by creating a separate demon threat that would constantly listen
for new line character.
Zitter similar to press and enter during the program execution and once new line character is received,
we interrupt this bomb threat.
Besides the knowledge of mooches threat, this task also and needs knowledge of input output streams
in Java.
In case you have never worked with AI streams, please watch my Java course, namely section about inputs
and outputs streams in Java.
The shared task is already about synchronization similar to the ones that we have reviewed in lessons,
but again seen task solution in the lesson and trying to implement it by itself.
It is different things.
So try to implement this task and understand better how SYNCHRONIZE Block works.
Task number four is a little bit more complex and sure, you have to find a maximum number in multidimensional
array.
It is recommended to create Israelian solution and single resolution in order you could see the benefits
of concurrent compute.
And also I recommend to solve this task twice in order to practice different things.
The first variant will be implementation was callable and future objects and the second variant will
be implementation.
With Countdown Lache Object.
Implementing this task force two different ways will let you understand how these two solutions are
different.
And what would you prefer to use in your projects?
And the last but not the least task.
Number five, the standard task about writers and readers.
Few students of mine has been asked to implement task and board readers and writers during the interviews.
This proves that this kind of tasks are popular.
During the interviews you have to implement reader and writer type and create objects of these types
that would work together.
Writer writes to the buffer readers read from above.
Everything is simple.
In the case there is nothing in Buffer.
Something should be written there in case Buffer is full, massages should be consumed.
There are some specific conditions that I would like you to implement in your solution.
For example, limit your demo with three cycles of writing and reading.
Limit your demo to three readers and one writer.
Only total duration of the program execution should not be longer than two seconds.
This check is also important.
In order you do not build logical thread synchronization, only using stress loops similar to the previous
task.
I'd like to ask you to implement this task in two different ways.
The first option is implementation with dummy object that will be used as monitor to synchronize all
threads.
Also, you can practice in using weight, modify and modify all methods and the second option is implementation.
With the API, it would be just perfect for you to understand how to use logs in places where we use
synchronize blocks and how flexible they are.
The reference to the source code of the solution to these tasks.
You can also find in attachments to the lesson in.
If you already pulled my cloning project, you can find all solutions and different versions of solutions
in the multiscreen package in Homburg package, all tasks have no in their name.
So I'm sure it would be easy for you to navigate between them, but try to solve tasks and buy yourself
first.
And after that, look at the solution in case for some reasons it is hard for you to solve some task.
Try to watch less than about a specific topic one more time.
If this still doesn't help, try to look at a solution and rewrite it.
As you understood, the things that I am trying to achieve is that you're trying to understand the solution,
but not just do it.
And remember, you are going to make a mistakes and that is fine.
Not learning from that mistakes.
It is the biggest mistake.
These are all tasks.
You are more than welcome to ask questions.
And as a beginner, in case of any.
That's it.
Thank you for your attention and see you in the next Larsons.