Managing client window access

I want to prevent the simultaneous access of different clients to a window, what’s the best way to do it?.

When a user opens the window store in the database the fact that the window has been opened by that user and the client.

Before opening the window check the database to see if a different client already has it open.

When closing the window update the database with the information that the window has been closed.

Use system.util.getClientId() to distinguish between different clients.

Instead of using the database the same thing could be done by storing a client ID to a memory tag. When the window is opened write the client ID of the client to the memory tag. Don’t let any other client open the window as long as a client ID exists in the memory tag. When the window is closed clear the memory tag.

The memory tag method seems a little easier to implement.

Thank you for both ideas.