You know how sometimes you're posting on an internet forum and someone else will post an intervening comment before you've submitted your comment but after you'd loaded up the page? Now the conversation doesn't make sense, or worse.
With a thread mutex, this won't happen. When you decide to post a comment, you first click on the "comment" button, as usual. However, this can either succeed (no-one else is posting, and your comment will go next) or fail (someone else has already claimed the lock). In the latter case, perhaps you could still write out your comment - but you'd be aware someone else's comment would go first. You may be able to join a queue to claim your turn at commenting, and perhaps review the subsequent comments to make changes before posting yours.
In branching comment systems, you'd only be locking the comment you were replying to.
Could this be used as a denial of service attack? Perhaps, but it would make sense to allocate users only a limited amount of lock time each day. There are a number of ways the timing system could be modified if it was found to be critical - only counting time if users are queuing, weighting by forum activity, giving bonuses to upstanding community members and so on.-- Loris, May 10 2022 This is a really good idea, but somebody has to have thought of it no? [+] Regardless.-- doctorremulac3, May 10 2022 Maybe. I checked the halfbakery but not the entire internet. Didn't see anything obvious on google, though.-- Loris, May 10 2022 Really seems like a no brainer but hey, somebody has to have thought of it first, might be you.-- doctorremulac3, May 10 2022 You [Loris] appear to have come face-to-face with the most virulent worm in the can. The worm has turned, so to speak.
Like many a boy who's had a girlfriend from Canada, I've played with Javascript without really doing anything. It was a toy language really. But now it's the most common programming language used by programmers today, and big boys like Google, Facebook, Microsoft and others are all building separate versions or "frameworks" for Javascript.
Why, you ask? I would ask everyone else the same question. It appears to come down mainly to the problem you're describing. I don't even know if Javascript has decent locking mechanisms, but the big boys are all breaking their heads over minor timing issues on a major scale.
You can understand why a Google or Facebook needs solutions at scale. But it's incomprehensible why programmers of lesser scale are getting 6 figures or more just to spaghetti the hell out of everyday life.-- 4and20, May 24 2022 //I would ask everyone else the same question//
I imagine [4and20] proceeding down the high street with his clipboard and his lonely quest. Or maybe a microphone.-- pertinax, May 24 2022 There are forums that will notify you of intervening replies that have been posted while you were writing your own.-- Cuit_au_Four, May 24 2022 [Typing...]
[This part added after making my second post. Normally, I'd delete the [typing...] tag when making my final post] [+] Inserting a placeholder annotation, then editing it isn't quite as convenient as the this idea, but if people followed this as a general method, it could accomplish pretty much the same thing (at least here on the Halfbakery).
Here's a proposed protocol: When you decide to annotate an idea, first post [Typing...]. Then refresh the screen to see if anyone else beat you to it. If not, edit your placeholder and submit. If someone put in a placeholder before you, go ahead and put in your own placeholder after theirs to reserve your place in line, but ideally wait until they finish posting before final edit on yours. If you are just making a short comment on something above and are impatient, you could add the text [sorry **** I posted this before you finished typing your last annotation] or something similar to reduce confusion.
Of course if half of the people start doing this and others don't, it could increase the confusion.-- scad mientist, May 25 2022 Simulated post from another user...-- scad mientist, May 25 2022 random, halfbakery