[libbluray-devel] Use private lock

hpi1 git at videolan.org
Tue Mar 29 12:50:53 CEST 2016


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Tue Mar 29 11:46:16 2016 +0300| [6e7939473cacec489d2cd3045116c5f4888db605] | committer: hpi1

Use private lock

> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=6e7939473cacec489d2cd3045116c5f4888db605
---

 .../tv/service/selection/ServiceContextFactoryImpl.java |   15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/libbluray/bdj/java/javax/tv/service/selection/ServiceContextFactoryImpl.java b/src/libbluray/bdj/java/javax/tv/service/selection/ServiceContextFactoryImpl.java
index 2940db4..9fb6b95 100644
--- a/src/libbluray/bdj/java/javax/tv/service/selection/ServiceContextFactoryImpl.java
+++ b/src/libbluray/bdj/java/javax/tv/service/selection/ServiceContextFactoryImpl.java
@@ -24,13 +24,11 @@ import javax.tv.xlet.XletContext;
 import org.bluray.ti.selection.TitleContextImpl;
 
 public class ServiceContextFactoryImpl extends ServiceContextFactory {
-    protected ServiceContextFactoryImpl() {
-        serviceContexts = new ServiceContext[1];
-        serviceContexts[0] = new TitleContextImpl();
-    }
+
+    private static final Object instanceLock = new Object();
 
     public static ServiceContextFactory getInstance() {
-        synchronized (ServiceContextFactoryImpl.class) {
+        synchronized (instanceLock) {
             if (instance == null)
                 instance = new ServiceContextFactoryImpl();
             return instance;
@@ -38,11 +36,16 @@ public class ServiceContextFactoryImpl extends ServiceContextFactory {
     }
 
     public static void shutdown() {
-        synchronized (ServiceContextFactoryImpl.class) {
+        synchronized (instanceLock) {
             instance = null;
         }
     }
 
+    protected ServiceContextFactoryImpl() {
+        serviceContexts = new ServiceContext[1];
+        serviceContexts[0] = new TitleContextImpl();
+    }
+
     public ServiceContext createServiceContext()
             throws InsufficientResourcesException, SecurityException
     {



More information about the libbluray-devel mailing list