Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Weird behavior

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am writing multithreading Java program. I have one thread waiting for another thread to reach some point in an infinite loop. However, after some iterations, it will never reach that same point again. It seems it stucks, but its state is still runnable. Can some one explain why it is like this? Is it possible the JVM will never execute a thread which is busy waiting or the OS will stop it? I debugged the program for a day but still can't figure out what is wrong... Please help.

Thanks in advance.
 
Marshal
Posts: 28271
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There were four instances of "it" in that question and I couldn't understand what they all referred to. However let me just say that if you have a thread waiting for an event that will never happen, then yes, that thread will indeed wait forever. Unless the thread is written so that it times out after a certain length of time, of course. However if you've programmed it so that it will wait indefinitely, then yes, it may wait indefinitely.
 
Once upon a time there were three bears. And they were visted by a golden haired tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic