JAVA????????????????????
??????????? ???????[ 2016/9/29 14:13:03 ] ????????Java ??????????? ???
??????????????JAVA?????????????????????????£????巽????????
???????????б?????????????????????????????????????????????????
???????????У???????????????MyClass.loop()????????????????????????????MyClass.setValue(100)??????????????????????????????????????
???????????
????public class MyClass{
????private static final String TAG="MyClass";
????private static int mValue=0;
????public static void setValue(int n){
????mValue=n;
????}
????public static void loop(){
????int value;
????while(value!=100){
????try{
????Log.i(TAG??"Value is "+value);
????Thread.sleep(1000);
????}catch(Exception e){
????}
????}
????}
????}
?????????????????????????
??????????synchronized?????
????public class MyClass{
????private static final String TAG="MyClass";
????private static int mValue=0;
????public static synchronized void setValue(int n){
????mValue=n;
????}
????public static synchronized int getValue(){
????return mValue;
????}
????public static void loop(){
????int value;
????while((value=getValue())!=100){
????try{
????Log.i(TAG??"Value is "+value);
????Thread.sleep(1000);
????}catch(Exception e){
????}
????}
????}
????}
???????????volatile?????
????public class MyClass{
????private static final String TAG="MyClass";
????private static volatile int mValue=0;//???volatile?????
????public static void setValue(int n){
????mValue=n;//?????mValue+=n????????????????????????synchronized
????}
????public static void loop(){
????int value;
????while(value!=100){
????try{
????Log.i(TAG??"Value is "+value);
????Thread.sleep(1000);
????}catch(Exception e){
????}
????}
????}
????}
????value++?????????value=1???????volatile????????????????????????????Щ?????????????????????????????synchronized?????
?????????synchronized???е???????????????????????????????????????????????????????????????????????????????????????????д????????????????????????????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11