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: 
The real problem you have is that `RunMyFunction` sometimes never terminates. As others have already stated, killing a thread is not intended in Java, so there is no good way to do it. Instead, you should reason about why you call a possibly non-terminating method. This looks like a code smell. Do the following:

If you are the author of `RunMyFunction`, make sure that it always terminates **or** it can be interrupted. You can do this by checking `Thread.currentThread().isInterrupted()` and `throw`ing an `InterruptedException` when it is. E.g:

```
void run(){

    while(...){ // this loop sometimes runs forever
       if(Thread.currentThread().isInterrupted())
           throw new InterruptedException(); // Now, we can "kill" this thread here
    } 

}

```
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.