A stochastic simulation technique for simulating the dynamic and rheological properties of simple and complex fluids