且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Scala对Java进行并发编程有什么优势?

更新时间:2022-01-02 01:54:06

并发规则是

1如果可以,请避免

2如果可以,则不分享

2 share nothing if you can

3分享不可变对象如果你可以

3 share immutable objects if you can

4要非常小心(和幸运)

4 be very careful (and lucky)

对于规则2,Scala通过以actor的形式提供一个开箱即用的完美集成的消息传递库来提供帮助。

For rule 2 Scala helps by providing a nicely integrated message passing library out of the box in the form of the actors.

对于规则3,Scala有助于使所有内容不可变默认。

For rule 3 Scala helps to make everything immutable by default.

对于规则4,Scala灵活的语法允许创建内部DSL,使其更容易,更少冗长,无法表达您需要的内容。即减少意外的地方(如果做得好)

For rule 4 Scala's flexible syntax allows the creation of internal DSL's making it easier and less wordy to express what you need consicely. i.e. less place for surprises (if done well)