FileDocCategorySizeDatePackage
jdk12CreateThreadAction.javaAPI DocJMF 2.1.1e1300Mon May 12 12:21:20 BST 2003com.sun.media.amovie

jdk12CreateThreadAction.java

/*
 * @(#)jdk12CreateThreadAction.java	1.3 02/08/21
 *
 * Copyright (c) 1996-2002 Sun Microsystems, Inc.  All rights reserved.
 */

package com.sun.media.amovie;

import java.lang.reflect.Method;
import java.lang.reflect.Constructor;

import java.security.PrivilegedAction;

public class jdk12CreateThreadAction  implements java.security.PrivilegedAction {

    private Class threadclass;
    private String name = null;
    public static Constructor cons;
    public static Constructor conswithname;

    static {
	try {
	    cons = jdk12CreateThreadAction.class.getConstructor(new Class[] {
		Class.class});
	    conswithname = jdk12CreateThreadAction.class.getConstructor(new Class[] {
		Class.class, String.class});
	} catch (Throwable e) {
	}
    }

    public jdk12CreateThreadAction(Class threadclass, String name) {
	
	try {
	    this.threadclass = threadclass;
	    this.name = name;
	} catch (Throwable e) {
	}
	
    }

    public jdk12CreateThreadAction(Class threadclass) {
	this(threadclass, null);
    }
    
    public Object run() {
	try {
	    Object object = threadclass.newInstance();
	    if (name != null) {
		((Thread) object).setName(name);
	    }
	    return object;
	} catch (Throwable e) {
// 	    System.out.println("amovie run: throws " + e);
	    return null;
	}
    }
}