2 messages in org.codehaus.groovy.user[groovy-user] Porting a java class to...
FromSent OnAttachments
st.clairMar 29, 2008 1:05 pm 
Adam RinehartApr 3, 2008 2:04 pm 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:[groovy-user] Porting a java class to groovyActions...
From:st.clair (st_c@flowja.com)
Date:Mar 29, 2008 1:05:52 pm
List:org.codehaus.groovy.user

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