FeaturesPluginsDocs & SupportCommunityPartners

NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

Help needed regarding ArrayList or similar containing activities to be executed

 
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users
View previous topic :: View next topic  
Author Message
anna_a



Joined: 02 Jul 2009
Posts: 9

PostPosted: Fri Jul 03, 2009 10:53 am    Post subject: Help needed regarding ArrayList or similar containing activities to be executed Reply with quote

Hi,

I want to create some kind of list, array or similar that contains activities (that are described in separate classes) that are supposed to be executed in a consecutive order.

For example we could have activities/classes "Warming up", "Running", and "Stretching" - what I want is for these to be gathered together somehow, so that I from the main method can extract the first item (warming up) of the container/list/array (or whatever it might be) and then execute that activity by creating the constructor of that class, and after that's been done move forward to the next activity, execute it, and so on. Any tips on how to achieve this would be greatly appreciated!

_________________
anna
Back to top
View user's profile Send private message
Franz
Posted via mailing list.





PostPosted: Sat Jul 04, 2009 7:15 am    Post subject: Help needed regarding ArrayList or similar containing activities to be executed Reply with quote

Hello,

anna_a schrieb:
Quote:
I want to create some kind of list, array or similar that contains activities (that are described in separate classes) that are supposed to be executed in a consecutive order.

For example we could have activities/classes "Warming up", "Running", and "Stretching" - what I want is for these to be gathered together somehow, so that I from the main method can extract the first item (warming up) of the container/list/array (or whatever it might be) and then execute that activity by creating the constructor of that class, and after that's been done move forward to the next activity, execute it, and so on. Any tips on how to achieve this would be greatly appreciated!

if you really need the constructor of the classes to be executed, you
can use s.th like:

List<Class> l = new ArrayList<Class>();
l.add(A.class);
l.add(B.class);
for (Class c : l) {
c.newInstance();
}

Regards
franz
Back to top
areeda



Joined: 28 Aug 2008
Posts: 88

PostPosted: Sat Jul 04, 2009 7:35 pm    Post subject: Re: Help needed regarding ArrayList or similar containing activities to be executed Reply with quote

anna_a wrote:
Hi,

I want to create some kind of list, array or similar that contains activities (that are described in separate classes) that are supposed to be executed in a consecutive order.

For example we could have activities/classes "Warming up", "Running", and "Stretching" - what I want is for these to be gathered together somehow, so that I from the main method can extract the first item (warming up) of the container/list/array (or whatever it might be) and then execute that activity by creating the constructor of that class, and after that's been done move forward to the next activity, execute it, and so on. Any tips on how to achieve this would be greatly appreciated!

I hope I'm not muddying the waters but I'm a bit confused at what you're trying to do.

If this is a simple single thread linear operation why not create and use the classes as you determine the need.

If on the other hand one task is generating the request and another is executing them, a queue or a blocking queue might be a better structure.

See

http://java.sun.com/docs/books/tutorial/collections/interfaces/queue.html

and

http://www.developer.com/java/ent/article.php/3645111

Joe
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB