Guitar music is often written in two parts, with both parts played by the same musician. You can compare it with a duet, where two different parts are written on two staves. In classical guitar music, the two parts are written on one staff. In this case, the melody part is played rest stroke with the fingers and the bass part is played free stroke with the thumb.