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

jadex.base.test.impl.SharedThreadPoolService Maven / Gradle / Ivy

Go to download

Jadex bridge is a base package for kernels and platforms, i.e., it is used by both and provides commonly used interfaces and classes for active components and their management.

There is a newer version: 4.0.267
Show newest version
package jadex.base.test.impl;

import jadex.bridge.IComponentIdentifier;
import jadex.bridge.service.types.threadpool.IThreadPoolService;
import jadex.commons.IChangeListener;

/**
 *  Helper class to allow sharing a thread pool service across platforms in same VM.
 */
public class SharedThreadPoolService	extends SharedService	implements IThreadPoolService
{
	/**
	 *  Get the instance.
	 */
	public  SharedThreadPoolService(IComponentIdentifier provider, SharedServiceFactory factory)
	{
		super(provider, IThreadPoolService.class, factory);
	}
	
	//-------- IThreadPool interface --------
		
	@Override
	public void execute(Runnable task)
	{
		getInstance().execute(task);
	}

	@Override
	public void executeForever(Runnable task)
	{
		getInstance().executeForever(task);
	}

	@Override
	public void dispose()
	{
		// IThreadPool method -> Should not be called on service
		throw new UnsupportedOperationException("Service shut be terminated via shutdown!");
	}

	@Override
	public boolean isRunning()
	{
		return getInstance().isRunning();
	}

	@Override
	public void addFinishListener(IChangeListener listener)
	{
		getInstance().addFinishListener(listener);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy