Not sure what the "real world" is. Here is some code I've used to start some threads:
Thread t1 = new Thread(new Runnable() {
public void run() {
...
Type: Posts; User: Norm
Not sure what the "real world" is. Here is some code I've used to start some threads:
Thread t1 = new Thread(new Runnable() {
public void run() {
...
No. Usually nothing is static except for the main() method.
Create a new thread with its run() method that calls the methods that you want to execute on that thread.
Put the calls to the methods inside separate run() methods and create and start threads as is done in post#1
That was explained in post#6. first method must finish before second method can start.
The two methods are executing on the same thread.
Please explain what doesn't happen.
Add the value returned by the System class's currentTimeMillis() method to all printed messages so you see when they were executed.
Add some more println statements where the threads are created that print out messages at each step in the execution of the main method that show when when each statement is executed.
Are you...
A thread starts executing the run() method. The run() method can call any other method it wants.
The OS determines when each thread gets to execute. The code in a thread must do something to...
If you don't want a method to execute on the run() method's thread don't call it from the run() method. Any method called from the run() method will execute on that thread. Any methods that the...