[Simpleweb-Support] Asynchronous services get blocked
Brought to you by:
niallg
From: Alvaro G. <alv...@gm...> - 2013-04-30 08:38:13
|
nice and easy to use but there seems to be a problem when you use several thread. I have a timeout for certain type of request the code is quite straightforward. I looks like the example, ie. this.executor = Executors.newCachedThreadPool(); @Override public void handle(Request request, Response response) { LOG.info("receiving request " + request.getAddress().toString()); Task task = new Task(request, response, cfg); executor.execute(task); LOG.info("Executing task"); } There is two differences In the Task compared to the examples in the homepage, 1)I have a Thread.sleep(millis) 2) I used Executors.newCachedThreadPool I tried the same sniper code outside the simpleframework and It worked fine. The problem is that it seems that when you have big loads of requests the simpleframework get a blocked handling like 3 requests at the time, ie. and it does not handle more request until the current Threads have runned completetly. In my eyes it should continue to handle requests even if some threads are sleeping, if you are using threads, the same sniper code outside simpleframework works fine so I don't think it has to do with the code. I tried also without Thread.sleep but I let the "task" do a lot of things that took about 10 seconds to finish. The same problem here simpleframework get blocked until it was finished with the current tasks, despite the fact it was supposed to run asynchronously. The same code works fine outside simpleframework, when I put it in a "main" class instead. I need some hints och help with this issue. ------------------------------ |