8185093: Expensive multi-core choke point when any graphics objects are created
Reviewed-by: prr, flar
This commit is contained in:
parent
5b641597ae
commit
af3dc52333
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -54,7 +54,6 @@ import sun.security.action.GetPropertyAction;
|
||||
*/
|
||||
|
||||
public abstract class GraphicsEnvironment {
|
||||
private static GraphicsEnvironment localEnv;
|
||||
|
||||
/**
|
||||
* The headless state of the Toolkit and GraphicsEnvironment
|
||||
@ -74,16 +73,14 @@ public abstract class GraphicsEnvironment {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the local {@code GraphicsEnvironment}.
|
||||
* @return the local {@code GraphicsEnvironment}
|
||||
* Lazy initialization of local graphics environment using holder idiom.
|
||||
*/
|
||||
public static synchronized GraphicsEnvironment getLocalGraphicsEnvironment() {
|
||||
if (localEnv == null) {
|
||||
localEnv = createGE();
|
||||
}
|
||||
private static final class LocalGE {
|
||||
|
||||
return localEnv;
|
||||
}
|
||||
/**
|
||||
* The instance of the local {@code GraphicsEnvironment}.
|
||||
*/
|
||||
static final GraphicsEnvironment INSTANCE = createGE();
|
||||
|
||||
/**
|
||||
* Creates and returns the GraphicsEnvironment, according to the
|
||||
@ -122,6 +119,15 @@ public abstract class GraphicsEnvironment {
|
||||
}
|
||||
return ge;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the local {@code GraphicsEnvironment}.
|
||||
* @return the local {@code GraphicsEnvironment}
|
||||
*/
|
||||
public static GraphicsEnvironment getLocalGraphicsEnvironment() {
|
||||
return LocalGE.INSTANCE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether or not a display, keyboard, and mouse can be
|
||||
|
Loading…
x
Reference in New Issue
Block a user