Hello,
I have the following class:
import java.util.concurrent.atomic.AtomicInteger;
public class ThreadId
{
// Atomic integer containing the next thread ID to be assigned
private static final AtomicInteger nextId = new AtomicInteger(0);
// Thread local variable containing each thread's ID
private static final ThreadLocal<Integer> threadId = new
ThreadLocal<Integer>()
{
@Override
protected Integer initialValue()
{
return nextId.getAndIncrement();
}
}
// Returns the current thread's unique ID, assigning it if necessary
public static int get()
{
System.out.println( "Thread ID: " + threadId.get());
return threadId.get();
}
public static void main( String[] args )
{
new ThreadId().get();
}
}
What is the groovy equivlent of this java construct in th above class?:
// Thread local variable containing each thread's ID
private static final ThreadLocal<Integer> threadId = new
ThreadLocal<Integer>()
{
@Override
protected Integer initialValue()
{
return nextId.getAndIncrement();
}
}
I am asking because no matter what I tried, Groovy does not recoginze the
method initialValue().
Thanks.
--
View this message in context:
http://www.nabble.com/Porting-a-java-class-to-groovy-tp16373926p16373926.html
Sent from the groovy - user mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email