When we need to do multiple tasks at the same time
We need multiple threads to run different tasks.
This time we need multi-threading
----------------------
Use of multithreading
The first is by inheriting the thread class
Override the Run method in this class
Then create the class object and call the Start method
-------
The second through the implementation of the Runnable interface
Overriding the Run method
Then new out a thread class object and will implement the class object of the Runnable interface
As a parameter.
-------
When we're doing multithreading, sometimes we need to share the same resources.
At this point, we need to use synchronization
is when one of the threads finishes running the synchronization block
To run the next thread to avoid errors
--------
Implementing synchronization
The synchronization code block we used
Synchronized keyword, in the back we need to add a
Lock, this lock is required when an object
Multiple threads require the same lock so that we can execute a thread
Then go on to execute another of course that's not necessarily.
Or we'll use the synchronous method
Java Threading Beginner (rough)