Barbara Walker, the ex-wife of John A. Walker Jr., who is accused of leading a spy ring for the Soviets, has told The New York Times she is considering withholding testimony against him unless the government agrees to grant her 22-year-old son, Michael, immunity from prosecution.

In its Friday editions, The Times reported that Barbara Walker, 47, who gave information to the FBI that led to her ex-husband's arrest, said in interviews that she also sent him a warning after turning him in "on the assumption that he would flee to the Soviet Union to avoid prosecution."

"I wanted to give John a chance to run," the Times quoted her as saying. "That bond goes a lot deeper than you think."

She said that knowing about her husband's activities yet covering them up "became a way of life," The Times reported, and that she told each of her four children during their teen-age years that he was a spy. "All I tried to do was tell them their father was not a good person, but he was still their father," The Times quoted her as saying.

She said she phoned the FBI last November after getting a phone call from one of her daughters, Laurel Walker Snyder.

She told The Times that she knew Mrs. Snyder's testimony would strengthen her case against her husband and her daughter's action "fortified her in her resolve to do what she had contemplated many times."

Her son, Michael, a Navy Yeoman who was serving as a communications specialist aboard the aircraft carrier Nimitz, also is charged with espionage and is accused of providing classified documents to his father for sale to the Soviets.

Also charged in the case are Arthur J. Walker, 50, a Navy veteran who is John Walker's brother and is employed by a defense contractor; and Jerry A. Whitworth, 45, an unemployed Navy veteran. All the defendants have pleaded not guilty to the charges against them.

Barbara Walker, who was divorced from her husband seven years ago and lives on Cape Cod with a 26-year-old daughter, Cynthia, and a grandson, told The Times that the FBI did not believe her for some months, in part because she had been drinking in the hours before she called the FBI and freely admitted doing so to the agent she talked to.