私はロックにちょっと錆びており、Androidアプリで簡単なネットワーク通信をしようとしています。言うまでもなく、AsyncTask
これらの通信を行うには android を使用する必要があります。完了するまでメインスレッドをロックするにはどうすればよいAsyncTask
ですか?
public int read(){
ReadTCPTask t = new ReadTCPTask();
boolean canGoOn = false;
// We can proceed once we acquire the lock?
while (!canGoOn)
canGoOn = lock.tryLock();
t.execute();
// something that will wait here until the asynctask is done?
return readSize;
}