Logic for controll concurrent in block or funciton

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 21:41 UTC
Read the original article Hit count: 331

Filed under:
|

1)My environment is web application, I accept large request from selvets.

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 most then 30,throws 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