tags:

views:

32

answers:

1

hi we try to implement a process like when a user does something, his company's credit will be deducted accordingly.

But there is a concurrency issue when multiple users in one company participant in the process because the credit got deducted wrong.

Can anyone point a right direction for such issue? thanks very much.

A: 

This is a classic problem that is entirely independent of the implementation language(s).

You have a shared resource that is maintaining a persistent data store. (This is typically a database, likely an RDBMS).

You also have a (business) process that uses and/or modifies the information maintained in the shared data store.

When this process can be performed concurrently by multiple actors, the issue of informational integrity arises.

The most common way to address this is to serialize access to the shared resources, so that the operation against the shared resources occur in sequence.

This serialization can happen at the actor level, or, at the shared resource itself, and can take many forms, such as queuing actions, or using messaging, or using transactions at the shared resource. Its here that considerations such as system type, application, and the platforms and systems that are used become important and determine the design of the overall system.

Take a look at this wikipedia article on db transactions, and then google your way to more technical content on this topic. You may also wish to take a look at messaging systems, and if you are feeling adventurous, also read up on software transactional memory.