Question: I have a Spotlight source in OpenGL, pointing towards a texture mapped sphere. 

I rotate the lightsource with the sphere, such that if I rotate the sphere to the 'non-light' side, that side should be dark. 

The odd part is, the spotlight seems to be shining through my sphere (it's a solid, no gaps between triangles. The light seems to be 'leaking' through to the other side. 

Any thoughts on why this is happening?

Screenshots:

[Front view, low light to emphasize the problem](http://www.logisticchaos.com/front.png)

[Back view, notice the round area that is 'shining through'](http://www.logisticchaos.com/back.png)

Answer: 
It is a little tricky, almost what Tom Hawtin wrote, but you must explicity request the monitor info when getting the ThreadInfo in dumpAllThreads.
Something like: 

```
    Object lock = ...
    ThreadMXBean mx = ManagementFactory.getThreadMXBean();
    ThreadInfo[] allInfo = mx.dumpAllThreads(true, false);
    for (ThreadInfo threadInfo : allInfo) {
        MonitorInfo[] monitors = threadInfo.getLockedMonitors();
        for (MonitorInfo monitorInfo : monitors) {
            if (monitorInfo.getIdentityHashCode() == System.identityHashCode(lock)) {
                StackTraceElement[] stackTrace = threadInfo.getStackTrace();
                // use the the Information from threadInfo
            }
        }
    }

```
Is this for diagnostic purposes, or is it for functionality you want to use as part of your application. If it's for diagnostics, then the various verbose logging solutions in the other answers here are probably enough to get you going. If you want to do this as part of functionality, then you really should use something more robust and flexible than the `synchronized` keyword, such as the `ReentrantLock` wizardry mentioned by @Tom.