Skip to content

Instantly share code, notes, and snippets.

@lhy880518
Created February 25, 2019 08:28
Show Gist options
  • Save lhy880518/72ff3562c3eacbee6b3cccb8ea2b3a9b to your computer and use it in GitHub Desktop.
Save lhy880518/72ff3562c3eacbee6b3cccb8ea2b3a9b to your computer and use it in GitHub Desktop.
JAVA method call to Thread
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.client.RestTemplate;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@Slf4j
public class RestCallToThread {
public void callUpload(String url, Map<String, Object> parameter){
ExecutorService executorService = Executors.newFixedThreadPool(3);
executorService.submit(() -> {
RestTemplate restTemplate = new RestTemplate();
restTemplate.postForObject(url, parameter, String.class);
});
executorService.shutdown();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment