View Single Post
  #9 (permalink)  
Old 10-07-2008, 11:51 PM
masijade masijade is offline
Senior Member
 
Join Date: Jun 2008
Posts: 549
masijade is on a distinguished road
Quote:
Originally Posted by mrhyman View Post
Hi Norm,

Sure I can do that:

I have a client server program I have

On the server there is the

Balance Variable

The Buyitem(Item,Quantity) method
the Sellitem(item,Quantity) method

The client can invoke

Buyitem which looks like this:

public buyitem(item,quantity){

if (balance > quantity * item){
//Ask seller's server to sell
sellitem(item,quantity)
balance = balance - quantity * seller.Getprice();

}

the sellitem method looks like

public sellitem(item,quantity){

balance = balance + Quantity * price

}

I need to make sure that the variable balance, quantity, etc on the server are synchronized with the correct calls.

There can be multiple servers: each managing their own balance and quantity

there exists the same number of clients as servers and the clients calls only the buyitem method which is directed towards the correct server who will sell his item.

therefore if I have 3 client/servers, 2 clients can invoke the buy method on the 3rd server.

I hope this makes it a bit clearer.

Okay, and like said, what you had looked okay (not neccessarily the way I would do it, but acceptable), but that due to the description you posted in the first sentence of your first post, they were probably looking for you to use the newer Lock objects. Try it with those, the tutorial has a few examples.
Reply With Quote