Logic for controll concurrent in block/method

Posted by Hlex on Stack Overflow See other posts from Stack Overflow or by Hlex
Published on 2010-03-19T21:38:04Z Indexed on 2010/03/19 22:01 UTC
Read the original article Hit count: 294

Filed under:
|
|

1)My environment is web application, I develop servlet to receive request.

A) In some block/method i want to control concurrent to not greater than 5
B) if there are 5 request in that block , the new coming must wait up to 60 second then throws error
C) if there are sleep/waiting request more then 30, the 31th request will be throwed an error

How I do this?

2)(Optional Question) from above I have to distribute control logic to all clustered host. I plan to use hazelcast to share the control logic (e.g. current counter)

I see they provide BlockingQueue & ExectorService but I have no idea how to use in my case. Please recommend if you have idea.

© Stack Overflow or respective owner

Related posts about java

Related posts about concurrent