Questions tagged [java.util.concurrent]

Java package which contains utility classes commonly useful in concurrent programming. This package includes a few small standardized extensible frameworks, as well as some classes that provide useful functionality and are otherwise tedious or difficult to implement.

java.util.concurrent is a core Java package which contains utility classes commonly useful in concurrent programming. This package includes a few small standardized extensible frameworks, as well as some classes that provide useful functionality and are otherwise tedious or difficult to implement.

Main components include:

  • Executors
  • Queues
  • Timing
  • Synchronizers, Semaphores, CountDownLatch
  • Concurrent Collections

More information is available at the JavaDoc description

1396 questions
0
votes
2 answers

Concurrency: implement connection timeout in custom connection pool

I have to implement my own connection pool, and I want the connection will automatically return to the pool after some CONNECTION_TIMEOUT. How can I achive that? Everything that comes to mind is to use ScheduledExecutorService in a separate thread…
VB_
  • 45,112
  • 42
  • 145
  • 293
0
votes
1 answer

CyclicBarrier code not working?

I got CyclicBarrier code from oracle page to understand it more. I modified it and now having one doubt. Below code doesn't terminate but If I uncomment Thread.sleep condition, It works fine. import java.util.Arrays; import…
0
votes
1 answer

Java fork join issue

I am learning fork-join technique in java and have written the following program. I am running a for loop (5 times) and I want to run the contents of the for loop in separate threads. This is happening correctly. The problem is that when all the…
0
votes
1 answer

Java Executor not working on JdbcTemplate

I am trying to execute a query with a jdbcTemplate using an executor object but for some reason the program doesn't go inside the jdbcTemplate. ExecutorService executor = Executors.newFixedThreadPool(NUMBER_OF_CONCURRENT_THREADS); …
locorecto
  • 1,178
  • 3
  • 13
  • 40
0
votes
1 answer

Extract and Insert concurrently into database using JdbcTemplate and BlockingQueue

I am extracting thousands of rows from one database table and inserting into another database table. I don't want to load all the records into memory and then insert into the other database. Because of that, I am trying to use a BlockingQueue to…
locorecto
  • 1,178
  • 3
  • 13
  • 40
0
votes
1 answer

Daemon threads in ForkJoinPool

According to Java Doc 7: Because ForkJoinPool uses threads in daemon mode, there is typically no need to explicitly shut down such a pool upon program exit Are there no other advantages? Is a daemon thread only different from a normal thread in…
GedankenNebel
  • 2,437
  • 5
  • 29
  • 39
0
votes
2 answers

Parallel tasks in Java

Suppose I have a few tasks to run in parallel in Java. Each task returns either success or failure. Each task has an associated deadline. If a task does not finish by the deadline it is interrupted (all tasks are interruptable) and returns…
Michael
  • 41,026
  • 70
  • 193
  • 341
0
votes
1 answer

Threads while looping video to JPanel using JavaFX

I'm working on a project for school at the moment where I'm trying to create an image gallery and video player. In the welcome-window I've created two JPanels with MouseListeners, one to hold an image and one to hold a looping video of approximately…
TheShahin
  • 153
  • 1
  • 12
0
votes
6 answers

Coordinate threads without wait/notify if possible

Besides wait/notify is there a cleaner way of notification of events among threads? E.g. if I want Thread X to notify ThreadY that something occured is there a better construct in concurrent package than build this on top of wait/notify? My…
Jim
  • 18,826
  • 34
  • 135
  • 254
0
votes
2 answers

Java avoid locking in case of disjoint sets

I have a use case like this. One of my method takes a List as parameter. I need to protect the critical section if and only if atleast one of the object is already locked by some other thread. How can achieve using java.util.concurrent package? I…
Gopal
  • 1,292
  • 3
  • 19
  • 41
0
votes
1 answer

Remove all edges touching a given vertex

So I'm trying to remove all edges of a SimpleGraph (undirected graph, JGraphT) but for some reason I keep getting ConcurrentModificationException. Here's what I'm trying to do: First, I have a class Point as fowllowed: class Point { private int…
0x56794E
  • 20,883
  • 13
  • 42
  • 58
0
votes
2 answers

Concurrent Modification Exception with ArrayList

I have a problem with ConcurrentModificationException. I have an ArrayList of Complex class that I defined. I added two Complexes, and try to do a for each loop but I get the ConcurrentModificationException. However, when I remove that line, I get…
0
votes
2 answers

How to make my algorithm in to process in parallel using Java CountDownLatch?

I am playing around with Java lacthes and wrote a piece of code to calculate some stuff in a parallel manner. The data, basically consists of a Map that each map has a list of numbers as value. My goal is to sum up all the values for all keys in…
Hossein
  • 40,161
  • 57
  • 141
  • 175
0
votes
1 answer

Concurrent requests via Apache Http Client (and java.util.concurrent) seem to finish correctly but crash my OS

i am currently learning to use the the concurrent features of Java provided by the package java.util.concurrent. As an exercise i tried to write a little program that could be used to performance test a HTTP API. But somehow my program is not…
0
votes
2 answers

Returning values from a call method to future object

How can i return the iterated set values which are of type string from a call method to a future object.do i need to store the iterated vales in a array and return that array or can any one help me out
babuchitti
  • 9
  • 1
  • 6