• Post Reply Bookmark Topic Watch Topic
  • New Topic

newInstance with arguments?  RSS feed

 
Gus Spain
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
i�m learning to do thread pools and i�ve found some good examples, but there�s something i would like to know. All the examples i�ve seen so far when they use newInstance in order to give the thread the code to work, they always use it with no arguments. How could i use newInstace with a class whose constructor requires arguments? For example, my class queryListener, its constructor is like this "queryListener(Socket socketa, Socket socket b, String text)", how should i do the newInstance if i want the thread to run the code inside my class?
Thanks!
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't understand how you use newInstance. Where can I find such an example?
 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Gus Spain:
How could i use newInstace with a class whose constructor requires arguments? For example, my class queryListener, its constructor is like this "queryListener(Socket socketa, Socket socket b, String text)"
You can't (not directly from a Class)! But lucky for you there's reflection:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!