Revision 5fd28c26
Added by Leszek Koltunski over 9 years ago
| src/main/java/org/distorted/library/EffectMessageSender.java | ||
|---|---|---|
| 50 | 50 |
|
| 51 | 51 |
private static Vector<Message> mList =null; |
| 52 | 52 |
private static EffectMessageSender mThis=null; |
| 53 |
private static volatile boolean mNotify = false; |
|
| 53 |
private static volatile boolean mNotify = false; |
|
| 54 |
private static volatile boolean mRunning = false; |
|
| 54 | 55 |
|
| 55 | 56 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 56 | 57 |
|
| ... | ... | |
| 62 | 63 |
|
| 63 | 64 |
static void startSending() |
| 64 | 65 |
{
|
| 66 |
mRunning = true; |
|
| 67 |
|
|
| 65 | 68 |
if( mThis==null ) |
| 66 | 69 |
{
|
| 67 | 70 |
mList = new Vector<>(); |
| ... | ... | |
| 81 | 84 |
|
| 82 | 85 |
static void stopSending() |
| 83 | 86 |
{
|
| 87 |
mRunning = false; |
|
| 84 | 88 |
|
| 89 |
synchronized(mThis) |
|
| 90 |
{
|
|
| 91 |
mThis.notify(); |
|
| 92 |
} |
|
| 85 | 93 |
} |
| 86 | 94 |
|
| 87 | 95 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 90 | 98 |
{
|
| 91 | 99 |
Message tmp; |
| 92 | 100 |
|
| 93 |
while(true)
|
|
| 101 |
while(mRunning)
|
|
| 94 | 102 |
{
|
| 95 |
//android.util.Log.d("SENDER", "running...");
|
|
| 103 |
//android.util.Log.i("SENDER", "sender thread running...");
|
|
| 96 | 104 |
|
| 97 | 105 |
while( mList.size()>0 ) |
| 98 | 106 |
{
|
| ... | ... | |
| 110 | 118 |
mNotify = false; |
| 111 | 119 |
} |
| 112 | 120 |
} |
| 121 |
|
|
| 122 |
mThis = null; |
|
| 123 |
|
|
| 124 |
//android.util.Log.i("SENDER", "sender thread finished...");
|
|
| 113 | 125 |
} |
| 114 | 126 |
|
| 115 | 127 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Further progress with SenderThread: make it possible to actually exit the thread on app exit.