This paper studies a spectrum sharing scenario between a cooperative relay network (CRN) and a nearby ad-hoc network. In particular, we consider a dynamic spectrum access and resource allocation problem of the CRN. Based on sensing and predicting the ad-hoc transmission behaviors, the ergodic traffic collision time between the CRN and ad-hoc network is minimized subject to an ergodic uplink throughput requirement for the CRN. We focus on real-time implementation of spectrum sharing policy under practical computation and signaling limitations. In our spectrum sharing policy, most computation tasks are accomplished off-line. Hence, little real-time calculation is required which fits the requirement of practical applications. Moreover, the signaling procedure and computation process are designed carefully to reduce the time delay between spectrum sensing and data transmission, which is crucial for enhancing the accuracy of traffic prediction and improving the performance of interference mitigation. The benefits of spectrum sensing and cooperative relay techniques are demonstrated by our numerical experiments.