Код: Выделить всё
...
Request request = new Request.Builder()
.url("http://hell.com/siners.txt")
.build();
client.newCall(request).enqueue(new Callback() {
@Override public void onFailure(Call call, IOException e) {
e.printStackTrace();
}
@Override public void onResponse(Call call, Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
if (!response.isSuccessful()) throw new IOException("Unexpected code " + response);
// Some work in Thread1
}
}
< /code>
thread2 < /h4>
...
Request request = new Request.Builder()
.url("http://hell.com/slutList.txt")
.build();
client.newCall(request).enqueue(new Callback() {
@Override public void onFailure(Call call, IOException e) {
e.printStackTrace();
}
@Override public void onResponse(Call call, Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
if (!response.isSuccessful()) throw new IOException("Unexpected code " + response);
// Some work in Thread2
}
}
Подробнее здесь: https://stackoverflow.com/questions/485 ... n-parallel