例如,我有以下课程:
public class MyClass{
private static int x;
private AsyncWorker worker;
public void myVoid(){
worker = new Worker;
worker.execute();
if (x == null){
Log.v("Say something: ", "x is null");
}
}
class AsyncWorker extends AsyncTask<Void, Void, Void>{
@Override
protected Void doInBackground(Void... arg0) {
// TODO Auto-generated method stub
x = 10;
return null;
}
@Override
protected void onPostExecute(Void result){
super.onPostExecute(result);
}
}
}
结果,它打印x
为空。将来有什么办法可以改变x
和AsyncTask
使用它的价值吗?