This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Has a single web view, and crashes if a request to obtain comes in and the | |
// cached instance is already allocated. | |
public static class SingularWebViewPool implements WebViewPool { | |
private WebView mCachedInstance; | |
private volatile int mBorrower; | |
private final int mSignature; | |
private final Context mAppCtx; | |
public SingularWebViewPool(Context appCtx) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.tutorials.vishal; | |
import com.tutorials.vishal.hierarchy.BaseWork; | |
import com.tutorials.vishal.hierarchy.RxWork; | |
import com.tutorials.vishal.hierarchy.Scheduler; | |
public class DemoClass { | |
void driver() { | |
BaseWork work = new BaseWork(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.tutorials.vishal; | |
import com.tutorials.vishal.hierarchy.BaseWork; | |
import com.tutorials.vishal.hierarchy.RxWork; | |
import com.tutorials.vishal.hierarchy.Scheduler; | |
import java.util.ArrayList; | |
import java.util.List; | |
public class DemoClass { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PCExample { | |
private volatile boolean shouldProduce = true; // Make this non-volatile, it will not work. | |
private int value = -1; // As we write the value before a write to volatile, this does not need to be volatile. All values | |
// will be flushed to main m/m along with volatile. Case of "happens before" guarantee. | |
public void startProducer() { | |
Runnable producer = () -> { | |
for (int i = 0; i < 10; i++) { | |
while (!shouldProduce) { } |
OlderNewer