正在方法调用语句同步执行,在它们的排列顺序? [英] Are method call statements executed synchronously, in the order in which they are written?

查看:126
本文介绍了正在方法调用语句同步执行,在它们的排列顺序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如:

void Function1()
{
  Function2();
  Function3();
}



威尔 Function3 是保证要等到功能2 完成每一次功能1 处理被称为?

Will Function3 be guaranteed to wait until Function2 is done processing each and every time Function1 is called?

推荐答案

Function3()等待,直到除非功能2()执行完毕。

YES. Function3() waits untill unless Function2() execution is Completed.

如果你想单独调用它们,你可以使用多线程概念

if you want to invoke them independently you can use Multi-Threading concept.

编辑:的建议使用注释任务发好得多,因为它是一个更高级别的概念。

as suggested in Comments using Task is much better than Thread as it is a higher level concept.

任务VS主题

尝试这种独立调用它们:

Try This to invoke them Independently:

using System.Threading.Tasks;

static void Main(String[] args)
        { 
            Task t1 = new Task(Function2);
            Task t2 = new Task(Function3);
            t1.Start();
            t2.Start();
        }



在这里,我们不能保证执行流程如何去on.because他们runindependently。

here we can not guarantee how the execution flow goes on.because they runindependently.

这篇关于正在方法调用语句同步执行,在它们的排列顺序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆