So David’s friend Hushai arrived in Jerusalem just as Absalom was entering the city.
Nothing, it seems, appeared to David more threatening in Absalom's plot than that Ahithophel was in it; for one good head, in such a design, is worth a thousand good hands. Absalom was himself no politician, but he had got one entirely in his interest that was, and would be the more dangerous because he had been all along acquainted with David's counsels and affairs...
Commenting on 2 Samuel 15:31-37
So Hushai David's friend came into the city,.... The city of Jerusalem, by the direction and persuasion of David, and in obedience to him, in order to serve him to the uttermost: and Absalom came into Jerusalem: just at the same time; so that he knew not that Hushai had been out of it, and been with David, and which also appears from what he said to him, Sa2 16:17.
Absalom came into Jerusalem - It is very probable that he and his partisans were not far from the city when David left it, and this was one reason which caused him to hurry his departure. Reader, behold in the case of David a sad vicissitude of human affairs, and a fearful proof of their instability.