Number of threads created grows

550 views Asked by At

I am currently using spark java version 2.5. And i am facing issues with the threads being created. I see the live threads keeps on growing. Below is the code public class LookupService {

public static void main(String[] args) {

    int maxThreads = 8;
    int minThreads = 2;
    int timeOutMillis = 30000;
    threadPool(maxThreads, minThreads, timeOutMillis);

    ServiceController service = new ServiceController();
    final Gson gson = new Gson();

    Spark.get("/sample", (request, response) -> {
        return "sample Spark";
    });

    Spark.get("/opt1", (request, response) -> {
        //SOme operation

    });


    Spark.post("/opt2", (request, response) -> {
        //SOme operation
    });

}

but when I run this application as jar and application start processing request . I can see the threads growing. I checked the threads number with help of VisualVm. Can you please help me on how to control the number of threads.

0

There are 0 answers