可以将同步视为AOP中的一个方面 [英] Can synchronization be treated as an aspect in AOP

查看:75
本文介绍了可以将同步视为AOP中的一个方面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我了解在AOP中,任何横切关注点,例如日志记录,事务等都可以视为一个方面,并且大多数AOP框架都很好地支持了此类横切关注点.

I understand that in AOP any cross cutting concerns such as Logging, transaction etc can be treated as an aspect and most of the AOP frameworks very well support these kind of cross-cutting concerns.

我的问题是

  • 可以将同步视为横切关注点吗?
  • 如果是,是否有任何现成的库(包括AspectJ和Spring AOP)支持该功能?

我搜索了但找不到很多示例.我遇到了一些受限的研究论文( 1 2 ).

I searched but could not find many examples. I came across some restricted research papers (1,2) though.

推荐答案

从理论上讲,可以有一个AOP框架来向一组方法/类添加同步.实施起来并不难.但这通常不是您想要的.太多的同步与太少的同步一样糟糕,因为您要么陷入死锁,要么对线程进行过多的排序,以致于您无法有效地使用多个内核.

In theory it's possible to have an AOP framework which adds synchronization to a set of methods/classes. It's not even hard to implement. But it is usually not what you want. Too much synchronization is just as bad as too few synchronization, because you either run into deadlocks or you sequentialize your threading so much, that you are not able to use multiple cores effectively.

恐怕多线程编程没有捷径.

I am afraid there is no no brainer shortcut to multithreaded programming.

这篇关于可以将同步视为AOP中的一个方面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆