Yao Ming reached out to Jeremy Lin about playing for his Shanghai Sharks during the NBA lockout, according to two league sources.

“Yao cares for [Lin’s] well-being,’’ one person familiar with the relationship said. “He’s that kind of guy.’’

Lin said he would have considered playing overseas had the Knicks waived him before his contract became fully guaranteed.

“I wasn’t considering that just yet,” Lin said, “but I figure if I get waived before the [Feb. 10] deadline and there’s nothing left, you know, maybe I do need to go overseas, but God works in mysterious and miraculous ways.”