It's not just native code. Almost all of SWT is written with an asumption of single-threaded access.
To make a a widget field freely accessible from another thread ("thread-safe"), it's necessary to synchronize ALL accesses to that field. There are
38 references
to
blockSelection
in StyledText code.
For a single boolean flag, you could get away with making it volatile. But for more complex data types (starting with integers), and for more than one thread-safe field, you'd need actual locks. Moreover, the locks would likely have to cover whole method bodies, because proving the correctness of more granular locking isn't easy. Then, all variables accessed in those synchronized methods would have to become synchronized in other methods too. The cost of built-in thread safety escalates quickly. That's why SWT is single-threaded.
Re: checkWidget. Without it, it would be easy to write incorrect multi-threaded code that works most of the time. It's blockind the dangerous path of least resistance.