在Java中,不等待代码块/方法执行完成的正确方法/实践/实现/策略(或我们称之为什么)是什么?
假设有以下方法:
private void myMethod()
{
// Some lines of code here
.....
.....
.....
anotherMethod(); // or this could be a code block
// Again some lines of code here
.....
.....
.....
}
在这种情况下,我期望
myMethod()
不应该等待anotherMethod()
的代码执行完毕。同时我可以保证,在anotherMethod()
中执行的任何内容都不会影响到后续的代码执行。