How threads are executed in the memory?

前端 未结 2 1085
南旧
南旧 2020-12-12 01:40

I am learning about Thread in Java. I was tring to fetch which thread is running. But, I am not able to understand the order of the output.

Following is

2条回答
  •  情歌与酒
    2020-12-12 02:25

    First .. please format your code for better visibility.Then use java naming convention.To find them out look here. It seems that you are a beginner in Threads and not understanding them in the first glance is completely OK.The unexpected order is related to OS scheduling and the concept of executing instructions and not methods concurrently, this mean that concurrent execution does not mean that run method will run concurrently, that means that everything (every instruction) in that method can/will run concurrently. Just keep learning Threads are (maybe) the most difficult area of Java but also the most interesting.

提交回复
热议问题