All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.wrapper.spotify.SpotifyApiThreading Maven / Gradle / Ivy

There is a newer version: 9.1.1
Show newest version
package com.wrapper.spotify;

import java.util.concurrent.Callable;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class SpotifyApiThreading {

  public static final ExecutorService THREADPOOL = Executors.newCachedThreadPool();

  public static  CompletableFuture executeAsync(final Callable callable) {
    CompletableFuture future = new CompletableFuture<>();

    SpotifyApiThreading.THREADPOOL.execute(() -> {
      try {
        future.complete(callable.call());
      } catch (Exception e) {
        future.completeExceptionally(e);
      }
    });

    return future;
  }

}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy