- Nov 8, 2011
- 392
- 0
- 0
In theory, possibly, in practice, not even close. Anyway, let's not stray off-topic. Feel free to open another thread about it if you want to discuss the details.The notion that Java is slow has been like disproved a decade ago. In fact some stuff is faster than in C++ nowadays...so another misguided belief.
You've (still) got your definition of fine-grained locking all wrong. It is not a property of the lock implementation. You can have fine-grained locking by putting every other thread to sleep. It would be horribly slow, but it still counts. The real distinction is in how finely or coarsely you share resources between threads. For instance if two threads want to write 10 data structures into a table at specific locations, then coarse-grained locking would lock the entire table and allow one thread to write its 10 elements while the other one has to wait. With fine-grained locking each table entry would be locked individually, and as long as the threads don't try to access the same entry the writes can happen concurrently. But in the case of fine-grained locking there are a lot more locking operations going on, so the overhead of that can outweigh the benefit of concurrent writing.ReadWriteLock is fine-grained because you can read in parallel. Only writes block. And they also do with TSX.
The great thing about TSX is that developers only have to think in terms of coarse-grained locking, while at the hardware level it behaves as fine-grained locking. Or in other words it's like fine-grained locking but without the typical overhead and without the massive coding complexity of avoiding race conditions.
So no, ReadWriteLock is not fine-grained just because you can read in parallel. And no, TSX in most cases does not block on concurrent writes.
You still expect me to help you out when you accuse me of coming up with random stuff? Do your own research. Or keep believing that ReadWriteLock (and Java) is fast. I don't care.Link to said 10x more powerful implementation with according performance data? or are you again just coming up with random stuff?
Last edited: