質問

I can't seem to find the answer to this question I'm having:

Is the method from the ACRA library ...

ACRA.getErrorReporter().putCustomData(Name, Content);

... thread safe?

I'd like to call it from two different threads and I'm not sure if i should or not.

I've searched through the documentation but I wasn't able to find anything related to this unfortunately, or maybe I'm just a bad Googleler :)

役に立ちましたか?

解決 2

So I think I've figure it out.

Looking through the code I've noticed that the putCustomData method is in fact a call to a HashMap's method, more precisely put.

Upon further search I've found that the method put is not synchronized.

So the answer is no, calling putCustomData from two different threads can create problems for you.

For a solution to the problem: see 323go's idea below. In my case, I already had a singleton class which I used, so I just placed a synchronized method in that class in which I called the putCustomData method.

Note: If I am wrong, someone please let me know, but this is what I was able to find out.

他のヒント

If you're not sure, buy some insurance:

ErrorReporter er = ACRA.getErrorReporter();
synchronized( er ) {
    er.putCustomData( ..., .... );
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top