multithreading - Can classes in java that implement runnable have methods other than run()? -


I'm trying to apply a simple class like this:

  public Static zero main (string algos []) {try {myClass test = new thread (new myClass (stuff)); Test.start (); Test.join (); } Hold (Throttle T) {}}  

When I try to include the print () method in my class and I use it, then I will call the class "java.lang" The symbol can not be found "threads. I do not really need to make this thread, but I want to test it. Do I have to change this to work my print () method?

Edit: I'm sorry, I realized that I can print run () inside the function lock. Why can not I say it out? I do not understand if I am synchronizing or can I call the function outside the run / class?

EDIT2: Sorry, I erase names here.

EDIT3: I am currently doing this:

  thread test = new thread (new myClass (stuff)); Teste.start (); Teste.join ();  

If I use a new runner, it seems that I can not start () and join (). Is there any way to go about this?

EDIT4: OK, we try again: I have an environment, which is a class and I have my edge, which is another class. MyAgent thread is MyAgent needs my environment, so I was passing it as a parameter for the creator. However, I could not expand this thread because the constructor (mine environment) was not found. Do I have to set my environment through another function or can I pass it using the constructor?

Whatever methods you can apply, however, you need to make sure that The reference does not use the name of your class, and runnable:

  The public class applies MyRunner Runnable {@ Override Public Wide Run); Public Zero Some Else (); } Runner R = new Mirenner (); R.somethingElse (); // will not work, this method is not defined by runnab. Myrunner M = new Merarner (); M.somethingElse (); // Success!  

Comments