Skip to content
This repository has been archived by the owner on Feb 23, 2018. It is now read-only.

Commit

Permalink
Merge branch 'pulls/98'
Browse files Browse the repository at this point in the history
  • Loading branch information
trptcolin committed May 30, 2014
2 parents 1da562e + 6a1b6bf commit 2c64160
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/main/java/jline/TerminalFactory.java
Expand Up @@ -42,7 +42,7 @@ public class TerminalFactory

public static final String FALSE = "false";

private static final InheritableThreadLocal<Terminal> holder = new InheritableThreadLocal<Terminal>();
private static Terminal term = null;

public static synchronized Terminal create() {
if (Log.TRACE) {
Expand Down Expand Up @@ -109,11 +109,11 @@ else if (tmp.equals(NONE) || tmp.equals(OFF) || tmp.equals(FALSE)) {
}

public static synchronized void reset() {
holder.remove();
term = null;
}

public static synchronized void resetIf(final Terminal t) {
if (holder.get() == t) {
if(t == term) {
reset();
}
}
Expand Down Expand Up @@ -154,12 +154,10 @@ public static enum Flavor
}

public static synchronized Terminal get() {
Terminal t = holder.get();
if (t == null) {
t = create();
holder.set(t);
if (term == null) {
term = create();
}
return t;
return term;
}

public static Terminal getFlavor(final Flavor flavor) throws Exception {
Expand Down

0 comments on commit 2c64160

Please sign in to comment.