They actually tried that in my secondary school when someone in our class broke a window one day. They kept us in the class and decided we weren't going anywhere until the person who did it owned up.
Since nobody would "rat" on the guy, we were there for almost 2 hours and they even tried this stunt of getting each of us to write the name of who we thought done it on a piece of paper. I just wrote "I don't know", which I didn't, but that's a stupid idea as people could just write anyone's name and accuse them.
Of course the result did seem a little funny as the year head held a piece of paper and said "right, I have here the name of the student who I think is responsible". Just as she did, the culprit just stood up and owned up, saying "miss, it was me". She ripped the piece of paper to shreds, which shows that she clearly had someone else's name and was about to accuse them.
Still though, punishing the whole class wasn't working either way.