Hello, welcome back.
In this lesson, we're going to see how to suspend a task, so I'm going to make a copy of this last
project.
Copy and then paste over here, and then I'm going to call this number eight, suspending the task.
And I'm going to open it.
OK.
So let's get started.
We're going to start off by having all of the tasks created with the same priority level, so I'm going
to change the priority of blue over here to one such that they all have the same priority.
And then over here we did get priority.
I'm going to delete this.
We don't need this for this project.
We need such priority of blue.
I'm going to delete this.
So it looks like our task creation version.
We've created three tasks.
They all have priority of one.
And here are the task functions.
What I'm going to do is I'm going to make.
I'm going to make.
The red task suspend the blue task after a number of iterations and when I put a counter variable here
over here of great, you ain't 32 unaskable to which I shall call to suspend, which, of course, suspend,
monitor and assure the account that they would monitor when we should suspend just to demonstrate how
suspension works.
So come over here.
What I'm going to do is I'm going to add a bit of delay to each of our profilers, otherwise this is
just going to move very fast.
So I'll create a local rainbow over here.
Then I'll say four equals zero is less than.
Let's see, a hundred thousand I plus plus, okay, I'm going to do the same for the others.
Over here as well, then I'll copy this.
Then over here, the local is yeah.
OK, so here we are.
What I'm going to do is, like we said in red, we're going to suspend.
We're going to suspend.
We're going to suspend Lisa Bloom, so whenever Red executes, I'm going to incrementalists or spend
money to assess or spend money to.
Plus, plus.
Okay.
And then I'm going to see if suspend monitor.
It's just been monitored.
Alesi is greater than.
Or equal to 50, then we would we would invoke a piece of code.
Or invoke this function v task, suspend.
This is the function for suspending the task.
All we have to do is pass the task function here.
The task Hondo sorry, arguments.
OK, so let's see how that works.
The reason I'm using suspend Monitise, if we simply call V task suspend, then we would see that before
and after suspension changes.
So what we would see is actually we would see that all task will be running and then after a while would
stop running.
OK, I'll click here to view it.
Luca.
There's so little money here to build.
People successfully.
Quickly, let's get onto the board.
But eight.
OK.
Which.
So I'm going to come over here.
And I'm going to spend money to watch winter, where I spend money to controversy.
Ed, over here, then I'm going to click to run or iterate and suspend monitors currently 17, 18,
19.
I see, I see they're all going.
They are all iterates, and that's almost the same rate.
OK, you see where I spend money to pass 50 blue stopped moving, now we just have red and green moving.
So blue has been suspended, right?
So that is how we suspend a task.
So we suspend the task.
Right.
So I'm going to create another project or what I'm going to do is actually I'll leave this to you as
assignment.
So I, I want you to create a function or create a project in which the task suspends itself.
Remember, we saw that we said if you want to suspend a task, if you undertook the task to suspend
itself, you can either pass now or the task Hondo as the argument.
So I want you to to run the experiment and make sure it works just like we saw for the set priority
function.
OK.
Right.
So in the next lesson, we're going to see how to resume the task, we've seen how to suspend a task
here, we would have to find ways to resume them when we suspend him.
So I'll see you in the next lesson of a nice.