Fixed thread safety for Terminal implementations. Changed Terminal implementation on windows to Flush System.out/System.err

This commit is contained in:
Adam Murdoch
2012-09-08 09:08:43 +10:00
parent 1c3ab6a289
commit ab1487d215
11 changed files with 179 additions and 38 deletions

View File

@@ -9,8 +9,8 @@ import java.io.File;
/**
* Provides access to the native integrations. Use {@link #get(Class)} to load a particular integration.
*/
@ThreadSafe
public class Native {
private static final Object lock = new Object();
private static boolean loaded;
private Native() {
@@ -22,8 +22,9 @@ public class Native {
* @param extractDir The directory to extract native resources into. May be null, in which case a default is
* selected.
*/
@ThreadSafe
static public void init(File extractDir) {
synchronized (lock) {
synchronized (Native.class) {
if (!loaded) {
Platform platform = Platform.current();
try {
@@ -54,6 +55,7 @@ public class Native {
* machine.
* @throws NativeException On failure to load the native integration.
*/
@ThreadSafe
public static <T extends NativeIntegration> T get(Class<T> type)
throws NativeIntegrationUnavailableException, NativeException {
init(null);