Unmanned aerial vehicles (UAVs) is one of the promising technology in the future. A recent study claims that by 2026, the commercial UAVs, for both corporate and customer applications, will have an annual impact of 31 billion to 46 billion on the country's GDP. Shortly, many UAVs will be flying everywhere. For this reason, there is a need to suggest efficient mechanisms for preventing the collisions among the UAVs. Traditionally, the collisions are prevented using dedicated sensors, however, those would generate uncertainty in their reading due to their external conditions sensitivity. From another side, the use of those sensors could create an extra overhead on the UAVs in terms of cost and energy consumption. To deal with these challenges, in this paper, we have suggested a solution that leverages the chance-constrained optimization technique for avoiding the collision in an energy-efficient manner. Building on the expressions for the non-central Chi-square CDF and expected value, and through the convexification of the resulting expressions, the chance-constrained optimization program is transformed into a convex Mixed Binary Nonlinear one. The resulting program allows us to find the optimal safety distance that extends UAVs lifetime and allows every UAV to move with a guaranteed probability of collision between any pair of UAVs.