Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

多线程bug #6

Closed
netsword opened this issue Apr 25, 2016 · 1 comment
Closed

多线程bug #6

netsword opened this issue Apr 25, 2016 · 1 comment
Labels

Comments

@netsword
Copy link

ReflectUtil.class

private static final Map<String, Class<?>> name2ClassCache = new HashMap<String, Class<?>>();
...
Class<?> clz = name2ClassCache.get(className);
if (clz != null) {
    return clz;
}
clz = forNameWithoutCache(className);
if (clz != null) {
    // 应该没有内存消耗过多的可能,除非有些代码很恶心,创建特别多的类
    name2ClassCache.put(className, clz);
}

hashmap在多线程并发put/get时应该有问题

qdaxb added a commit to qdaxb/motan that referenced this issue Apr 25, 2016
@qdaxb
Copy link
Collaborator

qdaxb commented Apr 25, 2016

这里确实有可能出现并发问题,在返回值类型较多时有可能出现cpu占用高的问题,下个版本会修复。

  • [ ]

half-dead added a commit that referenced this issue Apr 25, 2016
replace cache map with thread-safe implemention. Fixes #6
@qdaxb qdaxb added the bug label Apr 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants