All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.wildfly.clustering.context.DefaultExecutorService Maven / Gradle / Ivy

There is a newer version: 5.0.7.Final
Show newest version
/*
 * Copyright The WildFly Authors
 * SPDX-License-Identifier: Apache-2.0
 */
package org.wildfly.clustering.context;

import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadFactory;
import java.util.function.Function;

/**
 * {@link ExecutorService} that performs contextual execution of submitted tasks.
 * @author Paul Ferraro
 */
public class DefaultExecutorService extends ContextualExecutorService {

	public DefaultExecutorService(Function factory, ClassLoader loader) {
		// Use thread group of current thread
		super(factory.apply(AccessController.doPrivileged(new PrivilegedAction() {
			@Override
			public ThreadFactory run() {
				return new DefaultThreadFactory(Thread.currentThread().getThreadGroup(), DefaultExecutorService.class.getClassLoader());
			}
		})), DefaultContextualizerFactory.INSTANCE.createContextualizer(loader));
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy