Created
February 25, 2019 08:28
-
-
Save lhy880518/72ff3562c3eacbee6b3cccb8ea2b3a9b to your computer and use it in GitHub Desktop.
JAVA method call to Thread
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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