threads/loading sounds

i don't get how each thread knows what it is supposed to do when start() is called. how does the program distinguish the start() and run() methods.

also, i'm just experimenting on sound. and i converted an mp3 file to an au on a website. then when i put it in my program it was rreeeaalllyy slow and some of my images no longer showed up. what would be the best way to load the au file. and should i use a separate thread?

[438 byte] By [stephensk8sa] at [2007-11-27 5:56:36]
# 1

> i don't get how each thread knows what it is supposed

> to do when start() is called. how does the program

> distinguish the start() and run() methods.

>

>

Did you read the threading tutorial?

In short. Run is the code you write that is what the thread is supposed to do. Start is what you call and then the VM does "magic" whereby it launches your run code in a new actual thread.

Maybe you could post a simple (no GUI) threading example and post whatever questions you have and then we/I could answer them.

cotton.ma at 2007-7-12 16:27:31 > top of Java-index,Other Topics,Java Game Development...
# 2

>Did you read the threading tutorial?

i read it briefly

>Maybe you could post a simple (no GUI) threading example

i dont hav a code example...

>Run is the code you write that is what the thread is supposed to do. >Start is what you call and then the VM does "magic" whereby it >launches your run code in a new actual thread.

i understand this, but if all the threads use the run() method, wouldnt the run() method be the same for evry thread, making all the threads do essentially the same thing... unless the threads were in different classes?

stephensk8sa at 2007-7-12 16:27:31 > top of Java-index,Other Topics,Java Game Development...
# 3

> >Did you read the threading tutorial?

>

> i read it briefly

>

Maybe you should read it more?

> >Maybe you could post a simple (no GUI) threading

> example

>

> i dont hav a code example...

>

> >Run is the code you write that is what the thread is

> supposed to do. >Start is what you call and then the

> VM does "magic" whereby it >launches your run code in

> a new actual thread.

>

> i understand this, but if all the threads use the

> run() method, wouldnt the run() method be the same

> for evry thread, making all the threads do

> essentially the same thing...

Yes. Although you could have different Runnable classes. Besides talking about loading images what you want to do is the same. The different part is what image you want to load. So each Runnable class would be loading a different image in that case.

cotton.ma at 2007-7-12 16:27:31 > top of Java-index,Other Topics,Java Game Development...