Harish Dadi
Harish Dadi

Reputation: 65

Method concurrency

Let's say I have two methods in a method

void hello(){
    method1();
    method2();
}

Does method2 start only after complete execution of method1 all the time?

Upvotes: 0

Views: 58

Answers (2)

Stephen C
Stephen C

Reputation: 719326

Yes. It is guaranteed. The body of a method is a block, and the JLS 14.2 states:

A block is executed by executing each of the local variable declaration statements and other statements in order from first to last (left to right).

Upvotes: 1

Axel Podehl
Axel Podehl

Reputation: 4323

yes, that's the definition of the language. If there is no threading involved, one method needs to return before the next one is invoked.

Upvotes: 2

Related Questions