When David was not permitted to build the temple, he proceeded,
among the last acts of his life, with the assistance of Zadok
and Ahimelech, to organize the priestly and musical services to
be conducted in the house of God. (1.) He divided the priests
into twenty-four courses (1 Chr. 24:1-19), sixteen being of the
house of Eleazar and eight of that of Ithamar. Each course was
under a head or chief, and ministered for a week, the order
being determined by lot. (2.) The rest of the 38,000 Levites
(23:4) were divided also into twenty-four courses, each to
render some allotted service in public worship: 4,000 in
twenty-four courses were set apart as singers and musicians
under separate leaders (25); 4,000 as porters or keepers of the
doors and gates of the sanctuary (26:1-19); and 6,000 as
officers and judges to see to the administration of the law in
all civil and ecclesiastical matters (20-32).

This arrangement was re-established by Hezekiah (2 Chr. 31:2);
and afterwards the four sacerdotal courses which are said to
have returned from the Captivity were re-divided into the
original number of twenty-four by Ezra (6:18).