Hi,

I am creating a web application that will be accessed by several different users who need to be coupled and to interact.

More specifically, I would like to let both of them call the same servlet instance and make the servlet start his operations only when both users already sent the request.

How can I do that?

Thank you in advance.

Rick The Mad

There can be an indefinite amount of time between the sending of request by 'n' number of users, not to mention you need to remember who has sent a reply. There is anyways only a single servlet instance; for each user request a new thread is allocated from the container thread pool and the service() method of the Servlet is called.

As far as the "how" part is concerned, it would be difficult to explain the entire solution here. One naive solution would be to use a database to maintain the counter for an operation; after 'n' number of users have requested an operation, you invoke that operation.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.