This file contains 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 uz.valijon; | |
import static uz.valijon.PackageState.CHECKED_CANNOT_BE_INSTALLED; | |
import static uz.valijon.PackageState.CHECKED_CAN_BE_INSTALLED; | |
import static uz.valijon.PackageState.UNCHECKED; | |
import java.util.ArrayList; | |
import java.util.List; | |
import java.util.Objects; | |
import java.util.stream.Collectors; |
This file contains 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
/** | |
* It is instantiated only once. | |
* However can be initialized one or more times per thread. | |
* The code prints something like this on console: | |
* field threadLocal has been instantiated! | |
* Thread with id = 10 | |
* Thread with id = 11 | |
* Thread with id = 12 | |
* */ | |
public class Bar { |
This file contains 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 ThreadLocalExample { | |
public static class MyRunnable implements Runnable { | |
private ThreadLocal<Integer> threadLocal = | |
new ThreadLocal<Integer>(); | |
@Override | |
public void run() { | |
threadLocal.set( (int) (Math.random() * 100D) ); | |
try { |