
public class Scoped {
  private record V(String v){}
  
  private static final ScopedValue<V> VAL = ScopedValue.newInstance();

  public void printMyVal(){
    System.out.println(VAL.get());
  }

  public void test(String ...values) {
    for ( String s: values) {
      ScopedValue.runWhere(VAL, new V(s), () -> printMyVal());
    }
  }
  
  public static void main(String[] args) {
    var s = new Scoped();
    s.test("one", "two", "three");
  }
}

