still, you are not doing the decay and restock in the main-thread. when your thread calls SaveCycle++; the value is set within the thread....
you should do for example a timed call to a method, which does the cleanup. then it is executed in the main-thread.
i also thought over the decaying stuff again, and you should also put the lines which find the items to decay in the main-thread, since there can be again some side effects when a mobile picks up an item which is marked to decay between finding the items to decay and the decaying itself...
same for the vendors.
and another little thing:
you do not need to build a new hashtable to map the mobiles serials to the values of world.mobiles, since you never use the keys in your code. just getting a deep copy of world.mobiles.values would be enough.
same goes for all the other saving methods, you never need the serials, since you iterate through the whole collection anyway.
it would also be interesting to know how much ram is used on that server normally, since i am pretty surprised memory still increases just a few mbs for a deep copy of a world as big as yours...
you should do for example a timed call to a method, which does the cleanup. then it is executed in the main-thread.
i also thought over the decaying stuff again, and you should also put the lines which find the items to decay in the main-thread, since there can be again some side effects when a mobile picks up an item which is marked to decay between finding the items to decay and the decaying itself...
same for the vendors.
and another little thing:
you do not need to build a new hashtable to map the mobiles serials to the values of world.mobiles, since you never use the keys in your code. just getting a deep copy of world.mobiles.values would be enough.
same goes for all the other saving methods, you never need the serials, since you iterate through the whole collection anyway.
it would also be interesting to know how much ram is used on that server normally, since i am pretty surprised memory still increases just a few mbs for a deep copy of a world as big as yours...