1
vote
6answers
54 views

Java threading and outputstream printinng issue

Hi I am just trying my hands with threading, Just a Request its not a homework or anything its just testing of my understanding of the subject, so those who doesnt like it please dont close it there ...
0
votes
1answer
48 views

multithreading to calculate primes java

I am trying to parallelize a prime number counter as an exercise. I have refactored the original code and separated the long loops from others so that I can parallelize them. Now I have the following ...
1
vote
1answer
26 views

Perform a task 'n' times in parallel

I am trying to figure out the easiest way to invoke a task 'x' times and all in parallel in java. The task has a string variable whose value should be unique for each invocation and it returns a ...
1
vote
0answers
18 views

Working with Executors and Handlers within a Android Service

First of all: I am a multi-threading newbie. So forgive my stupidity on this matter :) I want to accomplish the following: Startup an Android Service and initialize/start several threads next to ...
0
votes
4answers
81 views

If I simply need to guarantee `happens-before` relation, and not atomicity, should I use a concurrent class or a synchronized block?

I am developing a pool mechanism. Objects in the pool will be used by different threads. Thus I need to guarantee that there will be a happens-before relation when accessing non-final attributes of ...
0
votes
1answer
60 views

Multiple Threads spawning multiple threads and how to wait for child Threads

I have two arrays abc[100] and def[1000] and I have to find an array xyz[100] , where xyz[i] = minDistance(abc[i],def) i.e for every element in abc i have to find a corresponding nearest element in ...
0
votes
2answers
28 views

Restarting cancelled tasks in ScheduledThreadPoolExecutor

I am creating tasks with ScheduledThreadPoolExecutor and adding the Futures to a list as below in my ThreadFactory class. private static List<Future> futures; ........ ScheduledFuture sf = ...
1
vote
2answers
69 views

Non-blocking method to start several threads and run a callabck on the parent thread when all children have finished

The main thing is that the callback should be on the PARENT thread and not called from the task, which is finishing the job (e.g. NOT like ThreadPoolExecutor's afterExecute() hook). I'd like to have ...
0
votes
1answer
70 views

How to read data concurrently using java?

I have a method which takes a string as input and returns data from the DB based on the input string. I have an array of strings and I am currently passing each string as input and looping over the ...
2
votes
2answers
97 views

Will the use of volatile & atomic always ensures thread safety

I get mixed answer whenever I look for concurrent access , JCIP book I have already ordered and is on the way , but I want to nail this concurrency basics of mine , here is my scenario I have 3 ...
0
votes
1answer
79 views

Java Executor - not running threads in parallel

I am trying to execute independent task parallel using the java.util.concurrent.Executor. I have the following working code public class MiniTest { private static String[] input; ...
0
votes
2answers
42 views

Java semaphore + No synchronization lock is held when acquire() is called

I am not able to understand the meaning of below line which is provided on link JavaWorld No synchronization lock is held when acquire() is called because that would prevent an item from being ...
1
vote
2answers
54 views

Interrupting a Runnable with a method of the class

How can I write a method of a class implementing the Runnable interface (started from an ExecutorService) that would interrupt the thread? I know that I can use Future fut = es.submit(foo); (where es ...
1
vote
1answer
35 views

What is meant by cpu slack?

The following is an excerpt from the book Java Concurrency in Practice, Chapter 12.2 Testing for Performance where the author talks about throughput of a bounded buffer implementation. Figure 12.1 ...
1
vote
2answers
54 views

Iterating over ConcurrentSkipListSet with different thread removing elements

I have a ConcurrentSKipListSet, and I'm iterating over values in this set with a for-each loop. Another thread at some point is going to remove an element from this set. I think I'm running into a ...

15 30 50 per page