MASON-INTEREST-L Archives

December 2006

MASON-INTEREST-L@LISTSERV.GMU.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Sean Luke <[log in to unmask]>
Reply To:
MASON Multiagent Simulation Toolkit <[log in to unmask]>
Date:
Fri, 29 Dec 2006 10:34:40 -0500
Content-Type:
text/plain
Parts/Attachments:
text/plain (34 lines)
Jimmy, multiple agents will not access the variable simultaneously  
unless you have fired them in separate threads.  In the standard  
MASON distribution, this is only possible via ParallelSequence or  
AsynchronousSteppable.  So you'll need to be more specific about what  
you mean here.

As to concurrent access control, Java does this like any other  
multithreaded system.  Create a lock variable that both agents have  
access to -- perhaps an instance variable.  An empty array works nicely:

	Object[] lock = new Object[0];

Then later your agents access the variable of choice like this:

	synchronized(lock)
		{
		// do stuff with my variable
		}

Sean

On Dec 25, 2006, at 3:28 PM, Jimmy Ong wrote:

> Merry Christmas to all!
>
> Can someone show me how do i prevent concurrent access to some  
> variable
> between 2 or more agents? I tried to synchronize on state.schedule  
> or an
> arbitrary object, but it doesn't work.
>
> Thanks in advance,
> Jim.

ATOM RSS1 RSS2