package com.test;
public class MyThread extends Thread
{
@Override
public void run() {
System.out.println("run函数");
}
public void disp1()
{
System.out.println("disp函数1");
}
public void disp2()
{
System.out.println("disp函数2");
}
}
package com.test;
public class TestBlockingQueue {
public static void main(String[] args)
{
MyThread mt = new MyThread();
mt.start();
mt.disp1();
}
}
write this , why that run () function in disp1 () after execution ? Principle is what ?
------ Solution ---------------------------------------- ----
changed following a look at the results.
@Override
public void run() {
for (int i = 0; i < 10000; i++) {
System.out.println("run函数");
}
}
public void disp1()
{
for (int i = 0; i < 10000; i++) {
System.out.println("disp函数1");
}
}
------ Solution ------------------------------------- -------
thread's call , the order of execution is managed with a JVM .
------ Solution -------------------------------------- ------
mt.start(); // 当主线程可以理解为main,执行到这里,子线程mt起来之后,mt执行,main继续执行。这两个是同时运行的
mt.disp1();//到这里的话打印哪个都是不确定的。哪个快就执行哪个打印。
procedures according to the first floor you can see out.
------ Solution ------------------------------------ --------
Well, this order does not determine .
------ For reference only -------------------------------------- -
random ? Or a regular ?
------ For reference only -------------------------------------- -
me yesterday that no circular pen questions , you would like to explain this matter there is no fixed order of the thread's call it ?
------ For reference only -------------------------------------- -
oh , is uncertain , right !
------ For reference only -------------------------------------- -
OK
没有评论:
发表评论