I have a swollen, painful thumb that locks at the first joint. What should I do?

Maybe an injection. The tendon helps your finger bend and is lined by a sheath. It sounds like to may have inflammation of the tendon sheath causing locking when you bend it. This is called a trigger finger. When a hand orthopedist or rheumatologist evaluates you, they may recommend a steroid injection to relieve it.
See a hand surgeon. Sounds like a trigger thumb. It may help to splint the thumb at night to prevent it from being locked when you wake up. Also try soaking the hand in warm water several times a day. Anti-inflammatory medications also typically help. Your trigger may be severe enough, though, that you should see a hand surgeon. A cortisone injection may help, or you may need a straightforward surgery to fix it.