The alternative to C++ that I meant was Rust, which statically prevents data races.

...so long as your code doesn't use unsafe, neither directly nor transitively.