1 00:00:00,120 --> 00:00:03,320 Single threaded applications run everything on one thread. 2 00:00:06,630 --> 00:00:09,240 By default, every application has a main thread. 3 00:00:12,280 --> 00:00:15,970 Any single threaded application runs everything on the main thread. 4 00:00:19,540 --> 00:00:23,320 In this lesson, you will learn about the limitations of a single threaded app. 5 00:00:26,350 --> 00:00:30,190 Open up the folder for this lesson by following this path in your course of resources. 6 00:00:36,850 --> 00:00:38,360 OK, let's talk about the main thread. 7 00:00:38,380 --> 00:00:44,680 Every Java app has a default, a mean thread and a single threaded app runs everything on the main thread. 8 00:00:51,540 --> 00:00:55,560 If I run this app the way it is, it should be relatively fast. 9 00:01:01,170 --> 00:01:05,730 All of the code we have in Maine runs on the main thread, and it runs relatively fast. 10 00:01:06,300 --> 00:01:07,320 OK, simple enough. 11 00:01:08,460 --> 00:01:10,230 Let's uncomment this function call. 12 00:01:11,660 --> 00:01:16,940 And inside of the same thread, we're going to be performing a really long task and then we're going 13 00:01:16,940 --> 00:01:18,140 to be doing some other work. 14 00:01:20,470 --> 00:01:21,310 If I were on the up. 15 00:01:26,320 --> 00:01:28,480 Wow, that took really long. 16 00:01:29,230 --> 00:01:33,370 The problem is this task takes three whole seconds to process. 17 00:01:34,090 --> 00:01:36,630 Here we have all of our code running on the main threat. 18 00:01:37,030 --> 00:01:39,940 The first task takes three whole seconds to process. 19 00:01:43,630 --> 00:01:47,410 In other words, the task is blocking the thread for three seconds. 20 00:01:47,770 --> 00:01:48,940 That's really bad. 21 00:01:49,270 --> 00:01:52,810 And only after the three seconds this, our other tasks get processed. 22 00:01:57,400 --> 00:02:03,730 That being said, time intensive tasks should not block the main thread, time intensive tasks should 23 00:02:03,730 --> 00:02:04,990 run on another thread. 24 00:02:05,710 --> 00:02:07,930 And that's where concurrency comes into play. 25 00:02:12,910 --> 00:02:19,750 Let's recap you saw the limitation of a single threaded up time intensive tasks can block the main thread. 26 00:02:20,380 --> 00:02:23,020 A single threaded app runs everything on the main thread. 27 00:02:23,590 --> 00:02:28,510 If I run this app, the first task takes really long to process and blocks the main thread for three 28 00:02:28,510 --> 00:02:29,320 whole seconds. 29 00:02:29,560 --> 00:02:31,480 Then our other task can run. 30 00:02:32,110 --> 00:02:37,720 That being said, time intensive tasks such as this one should never block the main thread. 31 00:02:38,050 --> 00:02:42,430 They should be run on another thread, which is what we're going to look at in the next video.