Volatile variables and other variables

后端 未结 2 1851
旧时难觅i
旧时难觅i 2020-12-05 08:30

The following is from classical Concurency in Practice:

When thread A writes to a volatile variable and subsequently thread B reads t

2条回答
  •  忘掉有多难
    2020-12-05 08:55

    It means if you write to ten non-volatile variable and write to a volatile one, all the non-volatile variables must be set before the volatile one.

    If you read the volatile variable and all the non-volatile ones you can be sure that the order won't be swapped around.

提交回复
热议问题