-
January 29th, 2014, 05:44 PM
#1
java multi threading problems
Hi Guys!
I new to programming, and I've been trying to study threads in java. I've made this program and I want it to write out 'hi' 'my name is Rodger' in an infinite loop. As you guys can see I have 2 threads in this program and I want them to run in sync . However I've had major issues trying to debug my program, I think I'm really close, but I'm not sure where I've gone wrong!
public class MyThread{
public static void main (String args[])
{
String a ="Hi";
String b= "My name is Rodger";
}
class t1 extends Thread
{
public void run(){
boolean hi= true;
while (hi==true);
}
System.out.println(a);
}
class t2 extends Thread
{
public void run(){
boolean meh= true;
while (meh==true);{
System.out.println(b);
}
}
}
}
-
February 6th, 2014, 11:29 AM
#2
Re: java multi threading problems
1. Wrong forum. This is a C++ forum.
2. You must create two thread objects and also start them, otherwise nothing will happen.
3. Your code is also incorrectly written and will not compile - maybe try to fix that first!
Nobody cares how it works as long as it works
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|