/**
 * Copyright 2008-2009. Chongqing Communications Industry Services Co.,Ltd Information Technology Branch. All rights reserved.
 * <a>http://www.crunii.com</a>
 */
package com.crunii.micro.common.concurrent;

import java.util.concurrent.FutureTask;

/**
 * @author 田平 create 2021/12/21 14:17
 */
public class PriorityTask<V> extends FutureTask<V> implements Comparable<PriorityTask> {

	private PriorityCallable call;

	public PriorityCallable getPriorityCallable(){
		return call;
	}

	public PriorityTask(PriorityCallable<V> call) {
		super(call);
		this.call = call;
	}

	public PriorityTask(PriorityRunnable run, V v) {
		super(run, v);
		this.call = new PriorityCallable(run, v, run.getPriority());
	}

	@Override
	public int compareTo(PriorityTask o) {
		return this.call.compareTo(o.getPriorityCallable());
	}
}
