Question: Is it possible to access the type of a property from an attribute that has been implemented on to that property?

```
public class FooAttribute : Attribute
{
    public string GetPropertyName()
    {
        // return ??
    }
}

public class Bar
{
    [FooAttribute]
    public int Baz { get; set; }
}

```

I would like GetPropertyName() to return "Baz".

Answer: 
Java does not support killing a thread via any method on java.lang.Thread.

stop() and destroy() do look promising at first glance, but they have both been deprecated. 

The documentation for destroy states:

> 
> This method was originally designed to destroy this thread without any cleanup. However, the method was never implemented. If if were to be implemented, it would be deadlock-prone
> 
> 
> 

and stop:

> 
> This method is inherently unsafe. Stopping a thread with Thread.stop causes it to unlock all of the monitors that it has locked (as a natural consequence of the unchecked ThreadDeath exception propagating up the stack). If any of the objects previously protected by these monitors were in an inconsistent state, the damaged objects become visible to other threads, potentially resulting in arbitrary behavior. 
> 
> 
> 

Thus when the documentation says 'deprecated', what it really means is that they are broken and must never be used!?! The Java API designers put a lot of work into backwards compatibility of their APIs, where other languages would have removed these methods Sun decided to keep them as their internal guides (rightly or wrongly) do not permit the removal of a public api method.

So, the question remains. How is one to get a thread to exit from another thread? Sadly one must go out of ones way to poll an exit variable. This can be a custom variable, or it can be a standard flag within java.lang.Thread that is accessible via 'interrupted()'. The advantage of using interrupted() is that other Java APIs such as IO support this flag during otherwise blocking API calls and will exit throwing an InterruptedException. The detection of calling interrupt() is not immediate, as it sets a flag and relies on the Thread to poll the variable at some point in the future.

Oracle offers a tutorial on how to code using interrupt [here](http://docs.oracle.com/javase/tutorial/essential/concurrency/interrupt.html).
Using ExecuterService you can specify a timeout.

```
ExecutorService executor = Executors.newFixedThreadPool(1);
    List<Callable<String>> tasks = new ArrayList<Callable<String>>();

    tasks.add(new Callable<String>() {

        @Override
        public String call() throws Exception {
             int stat = RunMyFunction();
             return "Execution Finished";
        }
    });

    new Thread(new Runnable() {

        @Override
        public void run() {
            try {
                executor.invokeAll(tasks, 10, TimeUnit.SECONDS);
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

        }
    }).start();

```

invokeAll(...) is a blocking call so i've added inside a new thread.