Skip to content

Tag: multithreading

Java MultiThreading task, three smokers and one agent

the task consists of three smokers which are three threads and one class called Agent which has three attributes Tobacco, Lighters and Paper. Smokers only have one of these items with them, agent class is supposed to put two items randomly on the table and then Smoker is supposed to check if they are missing …

Count only currently active threads

I have a list of Thread and I want to count only currently active threads, but method isAlive() don’t work. How correctly is this or exist other method check for currently active threads. Answer tl;dr Compare the state of the thread: Here is an example making a stream from your list of Thread objects. O…

What Happens when a thread doesn’t throw an exception?

I notice, in this javadoc, https://docs.oracle.com/javase/7/docs/api/java/lang/Thread.UncaughtExceptionHandler.html that an UncaughtExceptionHandler is used for when an exception occurs but is not caught. But, will that thread fail quietly? I guess so, because it is going about its business asynchronously, bu…