So there are a few options, but if you actually want to generate a HTTP response instead of just dropping the connection then your application code is going to have to take some responsibility.
If all you want to do is drop the connection then just scheduling a task that does exchange.getConnection().close() is fine, no HTTP response will be returned to the client.
If you want to actually send a response to the client then you are going to have to have some kind of lock/CAS that prevents your application from writing once the timeout has taken effect.
Are you using the Servlet API or the HttpServerExchange API? The best way to approach this is a bit different depending on what you are doing.
Stuart