I just ran in to the concept of gas and found this community. This question and answer were particularly helpful, but they leave one thing unanswered for me:
If I send out a transaction with a given price I am willing to pay for gas and a cap on the gas that can be used, how do miners decide which of them should process it? Say the price I offer is really good. It seems to me they would all try to process it and collect the fee. Now say my computation runs out of gas, and all those miners try to collect the fee. I shouldn't be double-charged, yet the work was done multiple times.
Is there a system for laying claim to transactions so this duplication of work doesn't happen? If there is, how does it work? If there isn't, then which of the miners who take up my task gets to keep the fee?