Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## javax.media.nativewindow
Interface ToolkitLock

    public interface ToolkitLock

Provides an interface for locking and unlocking the underlying window toolkit, where this is necessary in the OpenGL implementation. This mechanism is generally only needed on X11 platforms. Currently it is only used when the AWT is in use. Implementations of this lock, if they are not no-ops, must support reentrant locking and unlocking.

The ToolkitLock implementation can be aquired by `NativeWindowFactory's getToolkitLock()`.

All toolkit shared resources shall be accessed by encapsulating the code with a locking block as follows.

        NativeWindowFactory.getDefaultFactory().getToolkitLock().lock();
        try {
          long displayHandle = X11Util.getThreadLocalDefaultDisplay();
          ... some code dealing with shared resources
          ... ie the window surface
        } finally {
          NativeWindowFactory.getDefaultFactory().getToolkitLock().unlock();
        }

The underlying toolkit's locking mechanism may relate to `NativeWindow`'s `lockSurface()`. Hence it is important that both implementation harmonize well, ie `lockSurface()` shall issue a ToolkitLock lock befor it aquires it's surface lock. This is true in the AWT implementation for example. Otherwise the surface lock would steal the ToolkitLock's lock and a deadlock would be unavoidable.

However the necessity of needing a global state synchronization will of course impact your performance very much, especially in case of a multithreaded/multiwindow case.

Method Summary
`void` | `lock()` Locks the toolkit.
`void` | `unlock()` Unlocks the toolkit.

Method Detail

### lock

    void lock()

  Locks the toolkit.

### unlock

    void unlock()

  Unlocks the toolkit.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright 2005 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.