Starting a new thread.... with some more ideas..
On 30 December 2014 at 23:39, Greg Wilkins <gregw_at_intalio.com> wrote:
> On 19 December 2014 at 10:30, Mark Thomas <markt_at_apache.org> wrote:
>
>> I like an earlier suggestion that calls to asyncContext.start(Runnable)
>> do not take effect until the container thread exists the context. That
>> solves a number of concurrency issues. Is there agreement on this? Is it
>> worth spinning this particular point out into a separate thread?
>>
>
> I like that semantic, but don't think we should change the existing method.
> Instead we could add either something like startDelayed(Runnable) but I
> don't like
> the name, but can't think of a better one; OR start(Runnable runnable,
> boolean delayed)
> which is a touch ugly also, but would allow us to deprecate the existing
> start(Runnable), so it was clear to users that they need to consider which
> version they want.
>
Hmmm other possibilities that I can think of are:
ServletRequest.startAsync(Runnable) // starts async and sets a thread to
be run when the thread returns from the dispatch.
AsyncContext.setRunnable(Runnable) // same kind of semantic as
setTimeout, is called after startAsync and before the return.
These APIs have the benefit of only allowing a single thread to have this
semantic, so the context does not have to carry around a list of Runnables
that will almost always be 0 or 1 in length.
cheers
--
Greg Wilkins <gregw_at_intalio.com> @ Webtide - *an Intalio subsidiary*
http://eclipse.org/jetty HTTP, SPDY, Websocket server and client that scales
http://www.webtide.com advice and support for jetty and cometd.