This week's book giveaway is in the Artificial Intelligence forum.
We're giving away four copies of Pragmatic AI and have Noah Gift on-line!
See this thread for details.
Win a copy of Pragmatic AI this week in the Artificial Intelligence forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Threaded classes  RSS feed

Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good day,

I'm beginner into the Java Thread Programming and I've read many hours on the subject without found my issue. I hope somebody can help me. My problem is: what is the best way to create non synchronised and non-blocking threads. Per example.

I have a short class A who I need access to his Getter. So i defined

I defined a class thread container

My reader need to read until the readLine() = true but that's still block the while of my two others threads. I have to press severals <ENTER> to unlock my other threads and execute their loop. By reading the Oracle Java Doc API, the object ConcurrentHashMap aren't a blockable object queue.

A hash table supporting full concurrency of retrievals and adjustable expected concurrency for updates. This class obeys the same functional specification as Hashtable, and includes versions of methods corresponding to each method of Hashtable. However, even though all operations are thread-safe, retrieval operations do not entail locking, and there is not any support for locking the entire table in a way that prevents all access. This class is fully interoperable with Hashtable in programs that rely on its thread safety but not on its synchronization details.

The best world IS HAVING my two Class_A can return a value into a LinkedQueue and the queued element are care by the ThreadContainer.


Mabe I made something wrong, dont use the correct class/object or simply have to run my class_C4(destruct_my_brain).run()

No seriously, I realy need help. I'm completely upsets and will very soon turn this project in C++ ;) but I need the Java portability so...

Thanks in advanced

Martin L.
Ranch Hand
Posts: 66
Android Eclipse IDE IntelliJ IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I assume that this section of code is running in such a tight loop that the main thread never yields to allow the other two threads to run. Throw a Thread.sleep(100) in the loop and see if that affects your outcome.
Martin Leduc
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For your information, this is my Reader Run Thread method.

Can we add a king of Timeout to the Readline() method???



  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!