How to make sure the task is finished

I have a question about the task.

task task1();
while(size < 10000) begin
register_write(XXXX); <== this register_write() is also a task
end
endtask

task task2();
… // some other things to do
endtask

and in my test, I’d like to trigger task1 firstly and then task2. but I want to make sure all stuff in task1 is finished before task2 begins. How to handle this ? Thank you!

In reply to zz8318:

Tasks are blocking. If you call the tasks sequentially, the second task won’t start until the first task is complete. This changes if you use fork statements.

In reply to cgales:

I am sorry the scenario I described is not correct. Please ignore my question above.

Here is what I asked for help.

task my_task1();
while(size < 10000) begin
my_sub_task();
end
endtask;

task my_sub_task();
my_trans tr;
tr.set_parent_sequence(my_seq);
tr.set_sequencer(my_sqr);
my_seq.start_item(tr);
my_seq.finish_item(tr);
tr.end_event.wait_on();
endtask

task my_task2();

endtask

I want to know how to make sure all transaction is finished in the task1 (or say in my_sub_task) before my_task2 is started.

Thank you !

In reply to zz8318:

My answer is the same. Is there something confusing in what I said?

In reply to cgales:

nothing. I am clear now. Thanks for your help !!