net.jcip.annotations.ThreadSafe Java Examples

The following examples show how to use net.jcip.annotations.ThreadSafe. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RunTableFactory.java    From audiveris with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * The concurrency aspects of the adapter depends on the underlying PixelFilter.
 *
 * @return true if safe, false otherwise
 */
@Override
public boolean isThreadSafe ()
{
    Class<?> classe = source.getClass();

    // Check for @ThreadSafe annotation
    ThreadSafe safe = classe.getAnnotation(ThreadSafe.class);

    if (safe != null) {
        return true;
    }

    // Check for @NonThreadSafe annotation
    NotThreadSafe notSafe = classe.getAnnotation(NotThreadSafe.class);

    if (notSafe != null) {
        return false;
    }

    // No annotation: it's safer to assume no thread safety
    return false;
}
 
Example #2
Source File: RunsTableFactory.java    From libreveris with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * The concurrency aspects of the adapter depends on the
 * underlying PixelFilter.
 *
 * @return true if safe, false otherwise
 */
@Override
public boolean isThreadSafe ()
{
    Class<?> classe = source.getClass();

    // Check for @ThreadSafe annotation
    ThreadSafe safe = classe.getAnnotation(ThreadSafe.class);

    if (safe != null) {
        return true;
    }

    // Check for @NonThreadSafe annotation
    NotThreadSafe notSafe = classe.getAnnotation(NotThreadSafe.class);

    if (notSafe != null) {
        return false;
    }

    // No annotation: it's safer to assume no thread safety
    return false;
}