President Barack Obama on Saturday praised the work the Black Lives Matter movement has done to highlight racial inequality, but also strongly cautioned activists that they needed to be realistic about their proposals and be willing to compromise.

Speaking at a town hall in London, the president mentioned Black Lives Matter specifically as he laid out his vision of how activists can achieve social change.

"As a general rule, I think that what, for example, Black Lives Matter is doing now to bring attention to the problem of a criminal justice system that sometimes is not treating people fairly based on race, or reacting to shootings of individuals by police officers, has been really effective in bringing attention to problems," Obama said.

But the president went on to say that activists needed to be realistic about what could be achieved immediately and sometimes needed to compromise to achieve long-term goals.

"One of the things I caution young people about, though, that I don't think is effective is once you’ve highlighted an issue and brought it to people’s attention and shined a spotlight, and elected officials or people who are in a position to start bringing about change are ready to sit down with you, then you can't just keep on yelling at them," Obama said.

Once activists get access to people in power, Obama said, they have a "responsibility to prepare an agenda that is achievable." Organizers, he continued, "sometimes need to take half a loaf that will advance the gains that you seek, understanding that there's gonna be more work to do, but this is what is achievable at this moment."

Black Lives Matter activists met with Obama at the White House in February and the president praised their "degree of focus and seriousness and constructiveness.” But not everyone was happy with the meeting. Aislinn Pulley, co-founder of Black Lives Matter Chicago, did not attend and called it a "sham," writing in a column that attending would only "legitimize the false narrative that the government is working to end police brutality and the institutional racism that fuels it."

Obama, who began his career as a community organizer, has frequently spoken about social change as something that comes gradually through the hard work of multiple generations. He often points to a quote linked to Martin Luther King Jr. and the abolitionist Theodore Parker that "the arc of the moral universe is long, but it bends towards justice."

Obama added that he often sees activists who are good at drawing attention to an issue but are unwilling to compromise at all.

"Too often what I see is wonderful activism that highlights a problem, but then people feel so passionately and are so invested in the purity of their position that they never take that next step and say 'OK, well now I gotta sit down and try to actually get something done,'" he said.