Skip to content
Advertisement

Tag: multithreading

Creating threads without extends and implements

I was going through an old project (Java) in my company where I found the author (already left), creates and runs thread without extending the Thread class or implementing the Runnable interface. One noticable thing was that the class was a singleton class. There are no usage of thread pooling, or the new concurrent package from java. Code snippet outlines

synchronize two threads in java

I have two threads in my java programme, one is main thread and other thread is thread A which is spawned in main thread. now i want main thread to start thread A and wait till thread A has executed some part of its code in run method and thread A should suspend itself. main thread should then start running,

Using Java.io.Console.writer() Method in multiple threads

I am getting unexpected behavior when using console.writer() in multiple threads. In the below example, when program starts, I spawn a second thread, which is supposed to print to the console “Simulating Error.” every second. Then the main thread is supposed to print to the console when you type something like “get status 9999”: Instead what happens is after “Simulating

TCP threaded server/client

I’m trying to make a threaded TCP server that accept multiple client. It’s only accepting one client. Any idea on how to make the server accepting multiple client? Here is what I tried so far: I changed the server code. I ran both the server and the client, but it seems that it’s only one thread is working. Should I

Volatile variable explanation in Java docs

when a thread reads a volatile variable, it sees not just the latest change to the volatile, but also the side effects of the code that led up the change This is mentioned at http://docs.oracle.com/javase/tutorial/essential/concurrency/atomic.html Can someone please provide an example of this? This first gave me an impression that the thread that reads a volatile variable will synchronize with

Partition a Set into smaller Subsets and process as batch

I have a continuous running thread in my application, which consists of a HashSet to store all the symbols inside the application. As per the design at the time it was written, inside the thread’s while true condition it will iterate the HashSet continuously, and update the database for all the symbols contained inside HashSet. The maximum number of symbols

Run Handler messages in a background thread

I want to run some Runnable in a background thread. I want to use Handler because it’s convenient for delays. What I mean is Where runnable should be run in background Thread. Is it possible to create such Handler? Is there a “background” Looper somewhere or how can I create it? P.S. I know how to do it with a

Android Thread Allocation – growing heap?

Hi everyone out there, i am developing an android application against API 7 at the moment in which i use an activity which need to be restarted. Lets say my activity looks like this: The problem is that the gc doesnt seem to free the fullAnim thread so that the heap is growing by ~100K at every restart – till

Advertisement