Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

President Donald Trump on Wednesday said he may walk away from planned talks with North Korean leader Kim Jong Un if he isn’t confident that progress will be made.

Speaking to reporters during an appearance with Japanese Prime Minister Shinzo Abe, Trump said of the meeting with Kim "If we don’t think it’s going to be successful ... we won’t have it."

"If I think that it's a meeting that is not going to be fruitful, we’re not going to go," Trump said. "If the meeting when I’m there is not fruitful, I will respectfully leave the meeting."

"And we'll continue what we’re doing, or whatever it is that will continue. But something will happen," the president said.

In March, South Korean officials announced that Trump had agreed to meet with Kim, the dictator of isolated North Korea. The meeting had been pegged for some time in May, but officials have said it could happen in June.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

A senior U.S. official told NBC News on Wednesday that a number of locations had already been ruled out, including North Korea's capital, Pyongyang, as well as Beijing and Mongolia, all of which raise security concerns. U.S. officials are instead pushing for a more neutral location, preferably in Europe, with Switzerland among the top choices, the official said.

Trump and Kim traded fiery rhetoric last year and in January over North Korea’s ballistic and other missile tests, which included tests of intercontinental ballistic missiles. North Korea has conducted six nuclear tests, the most recent of which was in September.

The United Nations imposed punishing sanctions against North Korea in response, and China — North Korea’s ally and main trading partner — in September imposed limits on energy supplies to North Korea and would stop buying its textiles.

Trump's CIA Director and secretary of state nominee, Mike Pompeo, conducted an unannounced visit to North Korea and met with Kim over Easter weekend. News of the secret meeting was first reported by the Washington Post and later confirmed by Trump.

Trump on Wednesday thanked China’s president, Xi Jinping, and said "President Xi understands that this is a very important set of months that are lying ahead."

"Can he be better? I would say, yes, he can be better," Trump said. "But he’s been very good, and it’s had a big impact, and what we’ve done has had a big impact," Trump added.

Trump also said that his administration is "negotiating now" to try and secure the release of three Americans held in North Korea.

Asked about three Americans being detained in North Korea, Trump said, "We are doing our very best. As you know, they've been there a long time, and it's harsh treatment."

American student Otto Warmbier, arrested in that country and imprisoned for allegedly stealing a propaganda poster, was released in June but was unconscious and unresponsive and later died. He was 22.

South Korea and North Korea remain technically at war. South Korea’s senior presidential official said this week that during inter-Korea talks "we are reviewing the ways to transform the truce to a peace agreement."

Trump did not clarify what actions the United States might take if the proposed meeting with Kim fell through. The president said of the meeting, "I like always remaining flexible and we’ll remain flexible here."

"We've gotten us here and I think we're going to be successful," Trump said. "But if for any reason I feel we're not, we end."