diff --git a/content/en/docs/languages/java/instrumentation.md b/content/en/docs/languages/java/instrumentation.md index 2b9c92e22464..13be9c6960e8 100644 --- a/content/en/docs/languages/java/instrumentation.md +++ b/content/en/docs/languages/java/instrumentation.md @@ -988,14 +988,12 @@ The following example demonstrates how to propagate the context between threads: ```java io.opentelemetry.context.Context context = io.opentelemetry.context.Context.current(); -Thread thread = new Thread(new Runnable() { +Thread thread = new Thread(context.wrap(new Runnable() { @Override public void run() { - try (Scope scope = context.makeCurrent()) { - // Code for which you want to propagate the context - } + // Code for which you want to propagate the context } -}); +})); thread.start(); ```