发那科机器人子程序完成后跳入主程序怎么执行

发那科机器人子程序完成后跳入主程序怎么执行,第1张

1 子程序完成后,需要通过RET指令返回到调用该子程序的主程序中。

2 RET指令会将子程序的返回地址d出堆栈,并跳转到该地址执行主程序。

3 在主程序中,可以继续执行下一条指令,完成整个程序的执行。

java创建的线程在调用start方法后,进入就绪状态,但通常不会马上分配到CPU,处于线程就绪队列,需要等待时间片轮转到该线程获得CPU后才能执行。

如果你需要先执行新的线程,可以使用Thread类的join方法来等待该线程终止后,再继续往下执行,下面举个代码例子:

public class Test {

 int i = 0

 public static void main(String[] args) {

  Test test = new Test()

  MyThread1 myThread = new MyThread1(test)

  Thread thread = new Thread(myThread)

  thread.start()

  try {

   thread.join()//如果不调用此方法,打印结果为0

  } catch (InterruptedException e) {

   // TODO Auto-generated catch block

   e.printStackTrace()

  }

  System.out.println(test.i)

 }

}

class MyThread1 implements Runnable{

 

 Test test

 public MyThread1(Test test){

  this.test = test

 }

 @Override

 public void run() {

  test.i = 1 

 }

}


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/yw/12151863.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-21
下一篇2023-05-21

发表评论

登录后才能评论

评论列表(0条)

    保存