Merge pull request #47 from A248/master
Implement proper multi-threading
This commit is contained in:
commit
a6667129c9
|
@ -20,9 +20,10 @@ import java.util.Scanner;
|
|||
public class MineSkinFetcher {
|
||||
|
||||
private static final String MINESKIN_API = "https://api.mineskin.org/get/id/";
|
||||
private static final ExecutorService threadPool = Executors.newSingleThreadExecutor();
|
||||
|
||||
public static void fetchSkinFromIdAsync(int id, Callback callback) {
|
||||
new Thread(() -> {
|
||||
threadPool.execute(() -> {
|
||||
try {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(MINESKIN_API + id).openConnection();
|
||||
|
@ -50,7 +51,7 @@ public class MineSkinFetcher {
|
|||
exception.printStackTrace();
|
||||
callback.failed();
|
||||
}
|
||||
}).start();
|
||||
});
|
||||
}
|
||||
|
||||
public interface Callback {
|
||||
|
|
Loading…
Reference in New Issue