random click and gesture for android 7.0+!!!
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
package com.stardust.concurrent;
|
||||
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/5/8.
|
||||
*/
|
||||
|
||||
public class VolatileBox<T> {
|
||||
|
||||
private volatile T mValue;
|
||||
|
||||
public VolatileBox() {
|
||||
|
||||
}
|
||||
|
||||
public VolatileBox(T value) {
|
||||
set(value);
|
||||
}
|
||||
|
||||
public T get() {
|
||||
return mValue;
|
||||
}
|
||||
|
||||
public void set(T value) {
|
||||
mValue = value;
|
||||
}
|
||||
|
||||
public void setAndNotify(T value) {
|
||||
mValue = value;
|
||||
synchronized (this) {
|
||||
notify();
|
||||
}
|
||||
}
|
||||
|
||||
public T blockedGet() {
|
||||
synchronized (this) {
|
||||
try {
|
||||
this.wait();
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
return mValue;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user