Java - Syncronized Thread - Output in wrong order

前端 未结 3 1597
傲寒
傲寒 2021-01-19 06:40

I\'m reading Java The Complete Reference(9th Edition) after year of fooling around with Java. Been happy with the book so far but I now have a really strange problem with sy

3条回答
  •  粉色の甜心
    2021-01-19 07:41

    When you start multiple threads they all need some time to spin up, java does not garantee in which order this completes. The first thread which reaches the call() method will execute it, then the next. There is nothing in your code which enforces a sequence of that.

提交回复
热议问题