Skip to content

Commit

Permalink
优化几处锁条件处理
Browse files Browse the repository at this point in the history
  • Loading branch information
wyouflf committed Mar 19, 2017
1 parent cc25f47 commit 9d82db6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions xutils/src/main/java/org/xutils/http/HttpTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,8 @@ protected ResultType doBackground() throws Throwable {
if (cacheResult != null) {
// 同步等待是否信任缓存
this.update(FLAG_CACHE, cacheResult);
while (trustCache == null) {
synchronized (cacheLock) {
synchronized (cacheLock) {
while (trustCache == null) {
try {
cacheLock.wait();
} catch (InterruptedException iex) {
Expand Down Expand Up @@ -576,9 +576,9 @@ public void request() {
try {
boolean interrupted = false;
if (File.class == loadType) {
while (sCurrFileLoadCount.get() >= MAX_FILE_LOAD_WORKER
&& !HttpTask.this.isCancelled()) {
synchronized (sCurrFileLoadCount) {
synchronized (sCurrFileLoadCount) {
while (sCurrFileLoadCount.get() >= MAX_FILE_LOAD_WORKER
&& !HttpTask.this.isCancelled()) {
try {
sCurrFileLoadCount.wait(10);
} catch (InterruptedException iex) {
Expand Down
6 changes: 3 additions & 3 deletions xutils/src/main/java/org/xutils/image/ImageDecoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ static Drawable decodeFileWithLock(final File file,
Bitmap bitmap = null;
{ // decode with lock
try {
while (bitmapDecodeWorker.get() >= BITMAP_DECODE_MAX_WORKER
&& (cancelable == null || !cancelable.isCancelled())) {
synchronized (bitmapDecodeLock) {
synchronized (bitmapDecodeLock) {
while (bitmapDecodeWorker.get() >= BITMAP_DECODE_MAX_WORKER
&& (cancelable == null || !cancelable.isCancelled())) {
try {
bitmapDecodeLock.wait();
} catch (InterruptedException iex) {
Expand Down

0 comments on commit 9d82db6

Please sign in to comment.