Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Threads

 
Shiraz Khan
Ranch Hand
Posts: 51
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the code below, I want that thread A runs and prints 5 times, then wait is called to allow thread B run, and when B finishes A resumes back.

output should be like : AAAAABBBBBBBBBBAAAAA



Where am I wrong ?

[ July 10, 2008: Message edited by: Shiraz Khan ]
[ July 10, 2008: Message edited by: Shiraz Khan ]
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You've been around the ranch long enough to know that you should UseCodeTags when posting code of any length. Please go back and edit your post accordingly; it's unnecessarily hard to read as it is.

One thing that leaps out is that you're using "==" to compare strings. Never do that - that's what the equals method is for.
 
Shiraz Khan
Ranch Hand
Posts: 51
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for pointing out mistake.
But it is still not working
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, tell us what IS happening. Why do you think that might be?
 
Mihai Fonoage
Ranch Hand
Posts: 39
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Two thinks you should notice:
- you are calling wait on an object different than thread1
- your first condition in the second if statement

Mihai Fonoage
[ July 10, 2008: Message edited by: Mihai Fonoage ]
 
Shiraz Khan
Ranch Hand
Posts: 51
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the help. It is working now.
My understanding was wrong. I was calling wait on thread rather than on this object.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic