Single threaded applications run everything on one thread.
By default, every application has a main thread.
Any single threaded application runs everything on the main thread.
In this lesson, you will learn about the limitations of a single threaded app.
Open up the folder for this lesson by following this path in your course of resources.
OK, let's talk about the main thread.
Every Java app has a default, a mean thread and a single threaded app runs everything on the main thread.
If I run this app the way it is, it should be relatively fast.
All of the code we have in Maine runs on the main thread, and it runs relatively fast.
OK, simple enough.
Let's uncomment this function call.
And inside of the same thread, we're going to be performing a really long task and then we're going
to be doing some other work.
If I were on the up.
Wow, that took really long.
The problem is this task takes three whole seconds to process.
Here we have all of our code running on the main threat.
The first task takes three whole seconds to process.
In other words, the task is blocking the thread for three seconds.
That's really bad.
And only after the three seconds this, our other tasks get processed.
That being said, time intensive tasks should not block the main thread, time intensive tasks should
run on another thread.
And that's where concurrency comes into play.
Let's recap you saw the limitation of a single threaded up time intensive tasks can block the main thread.
A single threaded app runs everything on the main thread.
If I run this app, the first task takes really long to process and blocks the main thread for three
whole seconds.
Then our other task can run.
That being said, time intensive tasks such as this one should never block the main thread.
They should be run on another thread, which is what we're going to look at in the next video.