Revision 43eecb4c
Added by Leszek Koltunski over 3 years ago
src/main/java/org/distorted/library/message/EffectMessageSender.java | ||
---|---|---|
60 | 60 |
|
61 | 61 |
public static void startSending() |
62 | 62 |
{ |
63 |
mRunning = true; |
|
64 |
|
|
65 |
if( mThis==null ) |
|
63 |
synchronized(mLock) |
|
66 | 64 |
{ |
67 |
mList = new Vector<>(); |
|
68 |
mThis = new EffectMessageSender(); |
|
69 |
mThis.start(); |
|
70 |
} |
|
71 |
else |
|
72 |
{ |
|
73 |
synchronized(mLock) |
|
65 |
mRunning = true; |
|
66 |
|
|
67 |
if( mThis==null ) |
|
74 | 68 |
{ |
75 |
mLock.notify(); |
|
69 |
mList = new Vector<>(); |
|
70 |
mThis = new EffectMessageSender(); |
|
71 |
mThis.start(); |
|
76 | 72 |
} |
73 |
else mLock.notify(); |
|
77 | 74 |
} |
78 | 75 |
} |
79 | 76 |
|
... | ... | |
81 | 78 |
|
82 | 79 |
public static void stopSending() |
83 | 80 |
{ |
84 |
mRunning = false; |
|
85 |
|
|
86 |
if( mThis!=null ) |
|
81 |
synchronized(mLock) |
|
87 | 82 |
{ |
88 |
synchronized(mLock) |
|
89 |
{ |
|
90 |
mLock.notify(); |
|
91 |
} |
|
83 |
mRunning = false; |
|
84 |
if( mThis!=null ) mLock.notify(); |
|
92 | 85 |
} |
93 | 86 |
} |
94 | 87 |
|
Also available in: Unified diff
Firebase shows that we have a problem when an app is rapidly restarted, i.e. when is it paused and resumes within tens of milliseconds. Then sometimes the EffectMessageSender thread dies.
Attempt to limit this by synchronizing the whole 'start' and 'stop' methods, although I suspect this will still happen because the very methods are probably in such case called in the wrong order.