|
|
@ -1,8 +1,8 @@ |
|
|
|
package com.fr.design.mainframe.share.ui.online.resource; |
|
|
|
package com.fr.design.mainframe.share.ui.online.resource; |
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.SwingWorker; |
|
|
|
import javax.swing.SwingWorker; |
|
|
|
import java.util.concurrent.ArrayBlockingQueue; |
|
|
|
|
|
|
|
import java.util.concurrent.BlockingQueue; |
|
|
|
import java.util.concurrent.BlockingQueue; |
|
|
|
|
|
|
|
import java.util.concurrent.LinkedBlockingQueue; |
|
|
|
import java.util.function.Predicate; |
|
|
|
import java.util.function.Predicate; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -24,7 +24,7 @@ public class OnlineResourceManager { |
|
|
|
private SwingWorker<Boolean, Void> swingWorker; |
|
|
|
private SwingWorker<Boolean, Void> swingWorker; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final BlockingQueue<ResourceLoader> loaderBlockingQueue = new ArrayBlockingQueue<ResourceLoader>(100); |
|
|
|
private final BlockingQueue<ResourceLoader> loaderBlockingQueue = new LinkedBlockingQueue<>(); |
|
|
|
|
|
|
|
|
|
|
|
public void cancelLoad(Object key) { |
|
|
|
public void cancelLoad(Object key) { |
|
|
|
if (swingWorker != null) { |
|
|
|
if (swingWorker != null) { |
|
|
@ -39,11 +39,7 @@ public class OnlineResourceManager { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void addLoader(ResourceLoader loader) { |
|
|
|
public void addLoader(ResourceLoader loader) { |
|
|
|
try { |
|
|
|
this.loaderBlockingQueue.add(loader); |
|
|
|
this.loaderBlockingQueue.put(loader); |
|
|
|
|
|
|
|
} catch (InterruptedException e) { |
|
|
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void loadImage() { |
|
|
|
public void loadImage() { |
|
|
|