I agree with Gregg and Max. I always look at the situation and put myself in the dealer's position. Dissecting Luca's question a little more raises another issue that creates problems more than I'd like. "Player A bet 1500 Player B raises 3000." That would indicate a total wager of 4500...I know we have a rule on the books that reads:43 B) ...."declaring raise and the amount is the total bet"....
Trying to break down these situations will always create confusion. i.e. Player A bets 1500...Player B says "raise, 3000 more" Do you allow Player B his (intentional) amount to total 4500? Or are we that technical on these raise rules?
One other mention would be the dealer. In an ideal situation, the dealer would recognize the mistake about to be made by Player B and prevent his cards from hitting the muck. Problem solved. However, what if the dealer also thought that Player A folded? If I were dealing, I still would prevent B from mucking until I killed Player A's hand. Especially when we consider that Player B was in for all bets.
Luca, I'd also like to point out that your original question needs a slight correction. You wrote: "Player B thought Player A folded, and threw his cards, touching the muck, then realized the opponent
folded (I believe you meant to say, called)...."
Not trying to be too critical, I know I've made my share of mistakes on a regular basis.
Just trying to explain the question so others might participate in this important discussion.