Computer Science Canada Threads |
Author: | evogre3n [ Thu Oct 13, 2005 9:20 pm ] |
Post subject: | Threads |
Hey everyone, ive started Java gr.11 course, and for MyCreation assignment i have to create a bunch of threads to animate a bunch of objects in my assignment. the problem is, I am required to use the console class, with Ready to Program, and I have tried all kinds of parameter passes to the run() method in my thread to get it there including run (Console c) (with import hsa.Console; at the top) and all that, but it just doesnt work. Would love if someone could help out. thanks |
Author: | Martin [ Thu Oct 13, 2005 10:21 pm ] | ||||
Post subject: | |||||
Here are some code blocks from a simple threaded program.
|
Author: | evogre3n [ Fri Oct 14, 2005 10:08 am ] | ||
Post subject: | |||
Okay, i got that part. Now where in the thread where i need to "run" i have to use the console class, and have it write in the same window, called in the original program. ei
how do I pass the console into this thread? even if i stick import hsa.Console and state static Console c; it still doesnt work. Thanks a lot if you can help |
Author: | Hikaru79 [ Fri Oct 14, 2005 5:34 pm ] | ||||
Post subject: | |||||
You shouldn't be messing with threads yet if this is not something that you can easily answer yourself =/ But the short answer to your question is to pass the Console in to the constructor of the thread. So, for example,
And then when you create your thread, go:
|
Author: | evogre3n [ Fri Oct 14, 2005 8:51 pm ] |
Post subject: | |
thats EXACTLY what i did! and when i do that, i get a pointer null exeption error |
Author: | wtd [ Fri Oct 14, 2005 8:55 pm ] |
Post subject: | |
Have you initialized "c" before using it? |
Author: | evogre3n [ Sat Oct 15, 2005 8:21 am ] | ||
Post subject: | |||
Yes, in my main program:
|
Author: | evogre3n [ Sat Oct 15, 2005 8:33 am ] |
Post subject: | |
yipee, it works, seems the private Console c; made it work in the threads, thanks a lot. Now how bout creating flicker free graphics? |
Author: | Finaltank [ Thu Oct 20, 2005 6:48 pm ] |
Post subject: | |
I use ready alot for my Gr 11 course, do you know many advanced things in ready to program like how to use an image or stuff? The farthest we know is for loops Yeah you need c= new Console (); |
Author: | [Gandalf] [ Fri Oct 21, 2005 1:11 am ] |
Post subject: | |
I am fairly sure RTP can do normal Java just fine, look up some image tutorials for normal Java. Check the Java site, the tutorials here, google, etc. |