Questions tagged [java-threads]

For questions related to Java threads, including concurrent data structures, the fork-join framework, atomic classes, thread locking/synchronization, visibility and latency

Examples include:

  • Usages of java.util.concurrent.* data structures
  • Fork-join framework,
  • Atomic classes
  • Thread locking/synchronization, visibility and latency
1037 questions
0
votes
0 answers

Thread blocked when adding elements to HashSet

I'm using Java EntityManager to work with database in WSO2 AM and the application is working with several threads and sometimes the application is hanging when many requests comes to the application. The thread dump is as follows, Thread 23217:…
Lakmal Vithanage
  • 2,767
  • 7
  • 42
  • 58
0
votes
1 answer

Wrong order of tasks while synchronization

In my application I try to synchronize books with the MBaaS Backendless. Therefor I generate a List to save all book titles inside after getting them from Backendless. I get the correct data from the Server (without duplicates) but my for-loop is…
Timitrov
  • 211
  • 1
  • 3
  • 14
0
votes
1 answer

How to check if Java thread is idle or calculating?

I'm running some tick/timestep based simulations. After every tick objects move and states change. I'm trying to compare 3 different strategies for the same goal, the fastest strategy wins. The code looks as follows for(Strategy strategy :…
Hakaishin
  • 2,550
  • 3
  • 27
  • 45
0
votes
0 answers

thread inside IntentService stop updating Notification

i have intentservice associate with geofence. service is called a notification send and inside service their is a thread which update the notification after 10 sec. here is code: @Override protected void onHandleIntent(Intent intent)…
0
votes
1 answer

Blocking async queues Java

I'm trying to figure out a way to implement the following in Java. Thread1 will add jobs to queue1. Another different thread (Thread2) will add jobs to queue2. In the run() method of Thread1 I wait until there's a job in queue 1, and let's say I…
geek4079
  • 539
  • 2
  • 6
  • 15
0
votes
1 answer

Solaris unix NLWP limit

I have a question regarding increasing the limit of NLWP under one process on unix solaris. Suppose one java process is running and if I type command like this prstat It gives output with following content: java/2000 Here 2000 are NLWP. So how…
Hemal Pandya
  • 27
  • 2
  • 8
0
votes
3 answers

How to use wait() and notifyAll() to run thread one by one?

I write a House class, it has four synchronized method. I write four threads, and want they run one by one. but just first and second have run, the other havn't ? public class House { private boolean hasFoundation = false; private boolean…
Oolong
  • 171
  • 1
  • 1
  • 9
0
votes
1 answer

Creating threads on a JVM different than the one it is running

I have a server which has two JVM's and I have a class which creates dummy threads.This runs on lets say JVM A.How can I create these threads on JVM B programatically. After some research I came across…
Syam Kumar
  • 23
  • 6
0
votes
0 answers

Why do my actor tests fail non-deterministically?

I'm using Akka 2.4.2 with TestKit and Scalatest for writing and testing actors. It looks like there is a race condition whenever I'm inspecting some mutable state encapsulated by my actor. I have a really simple actor that saves some state in a…
nmurthy
  • 1,337
  • 1
  • 12
  • 24
0
votes
1 answer

Issues with Threads. Trying to test a timer that utilizes threads and seem to get stuck in a loop

My TEST creates an instance of SimpleTimer with 1000 as a milliseconds measure to delay the thread by 1 second. @Test public void testSimpleTimerAsThread() throws InterruptedException { SimpleTimer st = new SimpleTimer(1000); st.start(); …
0
votes
1 answer

Java many connections to API server with threads

I have created a custom web API for submitting data to a MYSQL server for my Java application. Within my Java application I need to add/update 200 rows, and I already have it making these requests one at a time. This can be pretty time consuming,…
Aaron
  • 306
  • 1
  • 4
  • 11
0
votes
1 answer

Joining a thread / process in Java after some time - Java

I have the following method, which executes a command as a process and returns the ouput: public String execute(String command) { StringBuffer output = new StringBuffer(); Process p; try { p =…
cybertextron
  • 10,547
  • 28
  • 104
  • 208
0
votes
0 answers

How to stop thread(s) properly while using CyclicBarriers

I have to make operations on a cache using many threads and thus have created 3 classes that extends from Thread (I realize now they can be Runnables also, or should be). Careful to note, these I'm running more than 1 instance of one of these…
0
votes
1 answer

Too much work on main Thread?

I have a fragment that has an image and a text. my App is running very slowly and the navigation drawer takes 30 secs to slide. What am i using in the main thread? I'm declaring the textView and ImageView in the Run() method to be compiled in a…
0
votes
1 answer

Why does this code output is 'thread:Thread..' ,not 'runnable:Thread..'?

I have a simple thread test code snippet,its pseudo code like this new Thread(new Runnable(){...implement run method....}){...override run method...}.start();. my problem is why does this code output is 'thread:Thread..' ,not …