Download 27 - Multithreading/001 Multithreading Overview_en.srt from Tan115/java-development-for-beginners-learnit: direct link, hf CLI and curl.
- Browser
- Download file 19.3 kB
-
https://huggingface.co/Tan115/java-development-for-beginners-learnit/resolve/main/27%20-%20Multithreading/001%20Multithreading%20Overview_en.srt
- Command line
-
hf download 'hf://Tan115/java-development-for-beginners-learnit/27 - Multithreading/001 Multithreading Overview_en.srt'
-
curl -L -o '001 Multithreading Overview_en.srt' https://huggingface.co/Tan115/java-development-for-beginners-learnit/resolve/main/27%20-%20Multithreading/001%20Multithreading%20Overview_en.srt
19.3 kB
| 1 | |
| 00:00:05,000 --> 00:00:11,000 | |
| Hello, yes, students today will start learning a new topic, Moonface Riden, this is huge topic, | |
| 2 | |
| 00:00:11,000 --> 00:00:16,000 | |
| and after this course, you will have a lot of knowledge that you can apply in different programming | |
| 3 | |
| 00:00:16,000 --> 00:00:21,000 | |
| languages to support not just execution, but in scope of this course. | |
| 4 | |
| 00:00:21,000 --> 00:00:27,000 | |
| I will show you how MultiThreaded works on Java examples and take into account this is the first lesson | |
| 5 | |
| 00:00:27,000 --> 00:00:32,000 | |
| of new topic, this lesson a little bit more theoretical one to be sure that we have enough high level | |
| 6 | |
| 00:00:32,000 --> 00:00:37,000 | |
| knowledge and understanding before we'll start sharing, quote, examples in the next lesson. | |
| 7 | |
| 00:00:37,000 --> 00:00:43,000 | |
| That's why today we'll focus our attention on such questions as what is the process in our computers? | |
| 8 | |
| 00:00:43,000 --> 00:00:45,000 | |
| What is the threat of execution? | |
| 9 | |
| 00:00:46,000 --> 00:00:52,000 | |
| What is multithreaded in programming also in this lesson and explain how multiscreen works and what | |
| 10 | |
| 00:00:52,000 --> 00:00:54,000 | |
| threats and translation means. | |
| 11 | |
| 00:00:54,000 --> 00:00:59,000 | |
| And the standard answers on these questions will bring us to the point where we can discuss with you | |
| 12 | |
| 00:00:59,000 --> 00:01:02,000 | |
| why multiscreen is needed and what a benefit, something which is written. | |
| 13 | |
| 00:01:03,000 --> 00:01:09,000 | |
| And also we'll discuss dark side of multithreaded to understand it, drawbacks and what we should always | |
| 14 | |
| 00:01:09,000 --> 00:01:12,000 | |
| take into account while working as much as freedom. | |
| 15 | |
| 00:01:12,000 --> 00:01:17,000 | |
| And the end of the lesson, I will give you an overview of what packages and tools we are going to learn | |
| 16 | |
| 00:01:17,000 --> 00:01:19,000 | |
| in this course in JDK. | |
| 17 | |
| 00:01:19,000 --> 00:01:25,000 | |
| Answering all these questions will give you insights on what we are going to learn in this course. | |
| 18 | |
| 00:01:25,000 --> 00:01:27,000 | |
| I believe we are good with our agenda for today. | |
| 19 | |
| 00:01:27,000 --> 00:01:34,000 | |
| Let's start and before we even start discussion of multithreaded in the program, let's understand what | |
| 20 | |
| 00:01:34,000 --> 00:01:36,000 | |
| the process is in computer science. | |
| 21 | |
| 00:01:36,000 --> 00:01:40,000 | |
| In simple words, process is an instance of a computer program. | |
| 22 | |
| 00:01:41,000 --> 00:01:42,000 | |
| You opened a glimpse. | |
| 23 | |
| 00:01:42,000 --> 00:01:45,000 | |
| It's a separate process to run as a Java program. | |
| 24 | |
| 00:01:46,000 --> 00:01:47,000 | |
| Is that a separate Java process? | |
| 25 | |
| 00:01:48,000 --> 00:01:53,000 | |
| Computer program is nothing more than a set of instructions for a machine but process. | |
| 26 | |
| 00:01:54,000 --> 00:01:56,000 | |
| It is an execution of these instructions. | |
| 27 | |
| 00:01:57,000 --> 00:02:00,000 | |
| A process has a self-contained execution environment. | |
| 28 | |
| 00:02:00,000 --> 00:02:04,000 | |
| That means that each process has its own memory space. | |
| 29 | |
| 00:02:05,000 --> 00:02:10,000 | |
| And as I said before, usually processes and programs are considered to be very close terms. | |
| 30 | |
| 00:02:11,000 --> 00:02:18,000 | |
| But what end user interaction with may be a set of processes that interact with each other doing no | |
| 31 | |
| 00:02:18,000 --> 00:02:21,000 | |
| such popular Internet browser as Google Chrome? | |
| 32 | |
| 00:02:21,000 --> 00:02:24,000 | |
| So long to go home and look at the task manager. | |
| 33 | |
| 00:02:25,000 --> 00:02:28,000 | |
| You will see separate processes for each stop in your browser. | |
| 34 | |
| 00:02:28,000 --> 00:02:33,000 | |
| But for the end user, Manglehorn perceived like a single application. | |
| 35 | |
| 00:02:33,000 --> 00:02:40,000 | |
| This is because most operating system support interpersonal communication resources, sap, pipes and | |
| 36 | |
| 00:02:40,000 --> 00:02:41,000 | |
| sockets. | |
| 37 | |
| 00:02:41,000 --> 00:02:47,000 | |
| These resources are used to interact between different processes, homes, and this is pretty straightforward. | |
| 38 | |
| 00:02:48,000 --> 00:02:51,000 | |
| Now let's understand what threat of execution is. | |
| 39 | |
| 00:02:51,000 --> 00:02:56,000 | |
| Each process may be executed in one or more threats of execution. | |
| 40 | |
| 00:02:56,000 --> 00:02:59,000 | |
| In this case, our program is executed concurrently. | |
| 41 | |
| 00:02:59,000 --> 00:03:03,000 | |
| In other words, some instructions are executed in parallel. | |
| 42 | |
| 00:03:03,000 --> 00:03:09,000 | |
| In computer science, concurrency is a duplicate of different parts or units of a program algorithm | |
| 43 | |
| 00:03:10,000 --> 00:03:17,000 | |
| or problem to be executed out of order or at the same time simultaneously without affecting the final | |
| 44 | |
| 00:03:17,000 --> 00:03:17,000 | |
| outcome. | |
| 45 | |
| 00:03:18,000 --> 00:03:22,000 | |
| So we can say that each process may be executed in multiple threats. | |
| 46 | |
| 00:03:23,000 --> 00:03:27,000 | |
| In the learning literature, you might even find mention about different name of abstracts. | |
| 47 | |
| 00:03:27,000 --> 00:03:34,000 | |
| Sometimes they're called as lightweight processes or threats, share process resources. | |
| 48 | |
| 00:03:34,000 --> 00:03:37,000 | |
| This is something that may cause issues during the multithreaded. | |
| 49 | |
| 00:03:38,000 --> 00:03:44,000 | |
| If you're allocated two gigabytes for a GBM, that means all created stress will work within these two | |
| 50 | |
| 00:03:44,000 --> 00:03:47,000 | |
| gigabytes and we'll share in between each other. | |
| 51 | |
| 00:03:48,000 --> 00:03:51,000 | |
| Knowing your memory will be allocated to threat of execution. | |
| 52 | |
| 00:03:52,000 --> 00:03:54,000 | |
| I hope you already know the answer to my next question. | |
| 53 | |
| 00:03:55,000 --> 00:03:56,000 | |
| What is a move to threaten? | |
| 54 | |
| 00:03:57,000 --> 00:04:01,000 | |
| To threaten is the process of execution of program in multiple threats. | |
| 55 | |
| 00:04:01,000 --> 00:04:04,000 | |
| Most of the operating systems nowadays support this feature. | |
| 56 | |
| 00:04:05,000 --> 00:04:11,000 | |
| You have multiple course in your processa multithreaded allows you to use all course for execution of | |
| 57 | |
| 00:04:11,000 --> 00:04:13,000 | |
| your program instructions. | |
| 58 | |
| 00:04:13,000 --> 00:04:21,000 | |
| EPU executes one task at a time and we as the software engineers will write instructions how to split | |
| 59 | |
| 00:04:22,000 --> 00:04:23,000 | |
| between different threats of execution. | |
| 60 | |
| 00:04:24,000 --> 00:04:25,000 | |
| That's what we are going to learn. | |
| 61 | |
| 00:04:26,000 --> 00:04:27,000 | |
| Let me explain it now. | |
| 62 | |
| 00:04:27,000 --> 00:04:32,000 | |
| How multiscreen program works on the high level, you always have one threat of execution. | |
| 63 | |
| 00:04:32,000 --> 00:04:34,000 | |
| One program just started. | |
| 64 | |
| 00:04:34,000 --> 00:04:36,000 | |
| That is your main threat of execution. | |
| 65 | |
| 00:04:37,000 --> 00:04:43,000 | |
| After that, you can run so-called child threats of execution and describe instructions what those threats | |
| 66 | |
| 00:04:43,000 --> 00:04:44,000 | |
| should work on. | |
| 67 | |
| 00:04:44,000 --> 00:04:48,000 | |
| In parallel, the different use cases of using Otis Redding. | |
| 68 | |
| 00:04:48,000 --> 00:04:49,000 | |
| And we'll look at them in the minute. | |
| 69 | |
| 00:04:50,000 --> 00:04:56,000 | |
| And now the important thing, how to synchronize the work of different threats imagines at your peril | |
| 70 | |
| 00:04:56,000 --> 00:04:58,000 | |
| to your work between multiple threats. | |
| 71 | |
| 00:04:59,000 --> 00:05:00,000 | |
| It is another thing that. | |
| 72 | |
| 00:05:00,000 --> 00:05:06,000 | |
| All of the threats are part of one program, and sometimes threat needs to update on the man's threat | |
| 73 | |
| 00:05:06,000 --> 00:05:09,000 | |
| about state of execution or result of execution. | |
| 74 | |
| 00:05:10,000 --> 00:05:15,000 | |
| But sometimes threats also need to interact with each other, take into account all threats, working | |
| 75 | |
| 00:05:15,000 --> 00:05:17,000 | |
| with some shared resource. | |
| 76 | |
| 00:05:17,000 --> 00:05:23,000 | |
| To rephrase this in simple words, imagine that you have a collection of users and you need to filter | |
| 77 | |
| 00:05:23,000 --> 00:05:28,000 | |
| this collection and remove users that have less than one thousand dollars total. | |
| 78 | |
| 00:05:28,000 --> 00:05:34,000 | |
| Check in your online shop and you decided to split the task between different threats of execution. | |
| 79 | |
| 00:05:34,000 --> 00:05:39,000 | |
| Each threat of execution works with shared resource collection of users. | |
| 80 | |
| 00:05:39,000 --> 00:05:46,000 | |
| Each threat takes users from this common collection to provide the result of the specific part of namely | |
| 81 | |
| 00:05:46,000 --> 00:05:53,000 | |
| users are equally distributed between different threats but all threats to removing users from the common | |
| 82 | |
| 00:05:53,000 --> 00:05:55,000 | |
| collection shared between all of them. | |
| 83 | |
| 00:05:55,000 --> 00:05:59,000 | |
| Can you understand what the shared resource mean on this example? | |
| 84 | |
| 00:06:00,000 --> 00:06:05,000 | |
| Let's review also other use cases of multithreaded programming and the one we might want to use this | |
| 85 | |
| 00:06:05,000 --> 00:06:05,000 | |
| approach. | |
| 86 | |
| 00:06:06,000 --> 00:06:08,000 | |
| I believe that we have already discussed the first case. | |
| 87 | |
| 00:06:09,000 --> 00:06:15,000 | |
| That is the case when different threats on these slides are marked with capital key and numbers reaching | |
| 88 | |
| 00:06:15,000 --> 00:06:22,000 | |
| out to shared resource that is marked with capital are in this case to modify the state of the resource. | |
| 89 | |
| 00:06:23,000 --> 00:06:27,000 | |
| So next year's case of using multithreaded is reading and writing operations. | |
| 90 | |
| 00:06:28,000 --> 00:06:33,000 | |
| You know that in Java, most of the input output streams, blogs and in process of execution. | |
| 91 | |
| 00:06:34,000 --> 00:06:37,000 | |
| So why don't we use features of malicious reading? | |
| 92 | |
| 00:06:37,000 --> 00:06:42,000 | |
| And in case we need to write, let's say, some file, we do this in a separate thread. | |
| 93 | |
| 00:06:42,000 --> 00:06:50,000 | |
| For example, a user asked us to do an expert of all users to see format and wants to download this | |
| 94 | |
| 00:06:50,000 --> 00:06:50,000 | |
| info. | |
| 95 | |
| 00:06:50,000 --> 00:06:52,000 | |
| No problem at all. | |
| 96 | |
| 00:06:52,000 --> 00:06:58,000 | |
| We are writing a separate threat of execution and other parts of our program proceed, working without | |
| 97 | |
| 00:06:58,000 --> 00:07:05,000 | |
| any free's user still able to click on other buttons and perform other operations while file downloading | |
| 98 | |
| 00:07:05,000 --> 00:07:06,000 | |
| is in progress. | |
| 99 | |
| 00:07:06,000 --> 00:07:07,000 | |
| Is that clear? | |
| 100 | |
| 00:07:07,000 --> 00:07:09,000 | |
| Same situation with redundant info. | |
| 101 | |
| 00:07:10,000 --> 00:07:16,000 | |
| Let's create a separate threat of execution that will show a status of uploading, and once uploading | |
| 102 | |
| 00:07:16,000 --> 00:07:21,000 | |
| is finished, we will be notified about that fact and we'll proceed from there. | |
| 103 | |
| 00:07:21,000 --> 00:07:27,000 | |
| Pay attention to how your clips is working when your important project or performance some other operations. | |
| 104 | |
| 00:07:28,000 --> 00:07:32,000 | |
| Eclipse is also Java application was multithreaded feature inside. | |
| 105 | |
| 00:07:32,000 --> 00:07:39,000 | |
| When any operation is performed, UI is not completely blocked and you still can perform as operations | |
| 106 | |
| 00:07:39,000 --> 00:07:40,000 | |
| with the clips in parallel. | |
| 107 | |
| 00:07:41,000 --> 00:07:47,000 | |
| The third case is a case when once to produce some data and other thread consumes this data. | |
| 108 | |
| 00:07:48,000 --> 00:07:54,000 | |
| These threads are working independently and potentially may interact with the help of the queue between | |
| 109 | |
| 00:07:54,000 --> 00:07:54,000 | |
| each other. | |
| 110 | |
| 00:07:55,000 --> 00:08:02,000 | |
| On the slide here you can see that we have producer and consumer producer send some item ready for processing | |
| 111 | |
| 00:08:02,000 --> 00:08:08,000 | |
| to the queue and consumer take this item from the queue when ready to process the next item. | |
| 112 | |
| 00:08:08,000 --> 00:08:12,000 | |
| The next case is a typical scenario with writers and readers. | |
| 113 | |
| 00:08:13,000 --> 00:08:19,000 | |
| Imagine that you have some shared resource, some shared buffer, and from one side you have writers | |
| 114 | |
| 00:08:19,000 --> 00:08:21,000 | |
| that might be separate services. | |
| 115 | |
| 00:08:21,000 --> 00:08:24,000 | |
| Read that, write some information to the buffer. | |
| 116 | |
| 00:08:24,000 --> 00:08:28,000 | |
| It can be is a strong representation of new objects or requests to the app. | |
| 117 | |
| 00:08:28,000 --> 00:08:30,000 | |
| Literally everything. | |
| 118 | |
| 00:08:30,000 --> 00:08:34,000 | |
| And on the other side, you have readers that read data from the buffer. | |
| 119 | |
| 00:08:35,000 --> 00:08:41,000 | |
| This example is different from all previous ones that we have discussed because here we have some specific | |
| 120 | |
| 00:08:41,000 --> 00:08:47,000 | |
| conditions on the ones that can write to the buffer at the point of time readers can to read during | |
| 121 | |
| 00:08:47,000 --> 00:08:53,000 | |
| the writing, all the readers may read data simultaneously, will have similar tasks in this course. | |
| 122 | |
| 00:08:53,000 --> 00:08:56,000 | |
| And I will show you how to solve this task. | |
| 123 | |
| 00:08:56,000 --> 00:08:58,000 | |
| Really interesting, don't you think so? | |
| 124 | |
| 00:08:59,000 --> 00:09:03,000 | |
| Probably these are the most popular use cases of using an Otis Redding approach. | |
| 125 | |
| 00:09:03,000 --> 00:09:10,000 | |
| Definitely there will be variations of these use cases and sometimes even different scenarios, but | |
| 126 | |
| 00:09:10,000 --> 00:09:13,000 | |
| we'll try to cover as much as we can on this course. | |
| 127 | |
| 00:09:13,000 --> 00:09:17,000 | |
| Now let's discuss advantages and disadvantages of multi threading approach. | |
| 128 | |
| 00:09:18,000 --> 00:09:20,000 | |
| Let's start from advantages of multithreaded. | |
| 129 | |
| 00:09:20,000 --> 00:09:22,000 | |
| It was to name a few important ones. | |
| 130 | |
| 00:09:22,000 --> 00:09:29,000 | |
| They are effective use of multiple course of your processa, high performance of your program during | |
| 131 | |
| 00:09:29,000 --> 00:09:32,000 | |
| execution of specific operations and data processing. | |
| 132 | |
| 00:09:33,000 --> 00:09:36,000 | |
| Good to use with operations that block mansard of execution. | |
| 133 | |
| 00:09:37,000 --> 00:09:43,000 | |
| Like I said before, in case of working with input output streams, application responsiveness, if | |
| 134 | |
| 00:09:43,000 --> 00:09:49,000 | |
| there is a need to perform, some operation application won't be frozen until that operation is completed. | |
| 135 | |
| 00:09:50,000 --> 00:09:53,000 | |
| Instead, I will execute request in a separate thread. | |
| 136 | |
| 00:09:54,000 --> 00:10:00,000 | |
| Probably these are main advantages of using these advantages, maintaining the Australian approach. | |
| 137 | |
| 00:10:00,000 --> 00:10:06,000 | |
| Across all over the world and in different programming languages, but there are always two sides of | |
| 138 | |
| 00:10:06,000 --> 00:10:10,000 | |
| a metal, all these advantages come with a group of disadvantages. | |
| 139 | |
| 00:10:10,000 --> 00:10:17,000 | |
| Some of them are it is easy to use is written incorrectly by saying this, I would like to highlight | |
| 140 | |
| 00:10:17,000 --> 00:10:18,000 | |
| that using what is right. | |
| 141 | |
| 00:10:18,000 --> 00:10:24,000 | |
| And it requires a good understanding of the toolset to implement concurrent execution of your program. | |
| 142 | |
| 00:10:24,000 --> 00:10:26,000 | |
| And that is relatively easy to do. | |
| 143 | |
| 00:10:26,000 --> 00:10:32,000 | |
| A mistake, for example, in synchronous court, sometimes also of execution doesn't play a big role. | |
| 144 | |
| 00:10:33,000 --> 00:10:39,000 | |
| Or you can write code in different ways with the thread and it is not so easy and straightforward. | |
| 145 | |
| 00:10:40,000 --> 00:10:46,000 | |
| You need to be sure about what pieces of code you need to synchronize between different threads, how | |
| 146 | |
| 00:10:46,000 --> 00:10:50,000 | |
| much stress you need, how to split work between threads and so on. | |
| 147 | |
| 00:10:50,000 --> 00:10:55,000 | |
| Incorrect and suitable usage of Montasser in May cause your performance. | |
| 148 | |
| 00:10:56,000 --> 00:11:00,000 | |
| You need to understand that multithreaded works perfectly, not for all tasks. | |
| 149 | |
| 00:11:01,000 --> 00:11:06,000 | |
| For example, you might not always see the benefit of using what is written while working with small | |
| 150 | |
| 00:11:06,000 --> 00:11:12,000 | |
| data in case you want to implement a certain approach and filter an election was one hundred integers. | |
| 151 | |
| 00:11:12,000 --> 00:11:18,000 | |
| More likely, it will take more time than performing the same operation synchronously in one step. | |
| 152 | |
| 00:11:19,000 --> 00:11:19,000 | |
| Why? | |
| 153 | |
| 00:11:20,000 --> 00:11:26,000 | |
| Because running threads, synchronization time, corporatization of different threads on different CPUs. | |
| 154 | |
| 00:11:26,000 --> 00:11:31,000 | |
| All of this takes time and we need to be sure that when we apply to certain approach, it is really | |
| 155 | |
| 00:11:31,000 --> 00:11:38,000 | |
| worth it and we will benefit from this and some mistakes even can bring it to the deadlock and lifework | |
| 156 | |
| 00:11:38,000 --> 00:11:39,000 | |
| cases. | |
| 157 | |
| 00:11:39,000 --> 00:11:45,000 | |
| When your program doesn't perform any useful activity, hard to debark application and find the mistake, | |
| 158 | |
| 00:11:46,000 --> 00:11:52,000 | |
| it is much harder to replicate an error in the multithreaded application than it is to do so in a single | |
| 159 | |
| 00:11:52,000 --> 00:11:53,000 | |
| threaded application. | |
| 160 | |
| 00:11:53,000 --> 00:11:58,000 | |
| As a result, it is more difficult to identify and verify root causes when error. | |
| 161 | |
| 00:11:58,000 --> 00:12:03,000 | |
| Secure testing process of multithreaded app is more difficult. | |
| 162 | |
| 00:12:03,000 --> 00:12:09,000 | |
| Testing the multithreaded application is more difficult than testing a single application because the | |
| 163 | |
| 00:12:09,000 --> 00:12:13,000 | |
| effects are often timing related and more difficult to reproduce. | |
| 164 | |
| 00:12:13,000 --> 00:12:19,000 | |
| It is difficult to introduce notice writing approach already created code because all code needs to | |
| 165 | |
| 00:12:19,000 --> 00:12:24,000 | |
| be analyzed by engineers, static variables, methods and locations and critical areas. | |
| 166 | |
| 00:12:24,000 --> 00:12:30,000 | |
| Everything needs to be reviewed and adjusted to make sure that the implementation of concurrent programming | |
| 167 | |
| 00:12:30,000 --> 00:12:32,000 | |
| approach will not affect all application. | |
| 168 | |
| 00:12:33,000 --> 00:12:39,000 | |
| The main disadvantages of multithreaded that we also need to consider when we want to create scalable | |
| 169 | |
| 00:12:39,000 --> 00:12:40,000 | |
| app with high performance. | |
| 170 | |
| 00:12:41,000 --> 00:12:47,000 | |
| In this course, we are going to learn tools for concurrent programming most tools, classes and interfaces | |
| 171 | |
| 00:12:47,000 --> 00:12:48,000 | |
| allocated in Java. | |
| 172 | |
| 00:12:48,000 --> 00:12:50,000 | |
| You can current package. | |
| 173 | |
| 00:12:50,000 --> 00:12:57,000 | |
| This package also has some set packages, also some main types like Runnable and Thread located in general | |
| 174 | |
| 00:12:57,000 --> 00:12:58,000 | |
| and package. | |
| 175 | |
| 00:12:58,000 --> 00:13:05,000 | |
| But most of the classes and interfaces, including concurrent collections, locks and other mechanisms | |
| 176 | |
| 00:13:05,000 --> 00:13:10,000 | |
| for stress synchronization executer services and most of the things that we are going to learn allocated | |
| 177 | |
| 00:13:10,000 --> 00:13:12,000 | |
| individual concurrent package. | |
| 178 | |
| 00:13:12,000 --> 00:13:15,000 | |
| We have really a lot of interesting things to learn. | |
| 179 | |
| 00:13:15,000 --> 00:13:19,000 | |
| Now let's recap what we have learned in this lesson and this lesson. | |
| 180 | |
| 00:13:19,000 --> 00:13:22,000 | |
| We learned what the process is and what the threat is. | |
| 181 | |
| 00:13:23,000 --> 00:13:28,000 | |
| We also learned what is a multiscreen program programming now, you know, the most popular use cases | |
| 182 | |
| 00:13:28,000 --> 00:13:30,000 | |
| of not just training programs. | |
| 183 | |
| 00:13:30,000 --> 00:13:34,000 | |
| We learned advantages and disadvantages of concurrent programming. | |
| 184 | |
| 00:13:35,000 --> 00:13:36,000 | |
| That's all for this lesson. | |
| 185 | |
| 00:13:36,000 --> 00:13:39,000 | |
| Looking forward to seeing you in the next lesson. | |