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
1 answer

loopers in java vs thread without looper, and correct way to stop looper?

My question is in regards to java loopers and also how to stop them the correct way. Lets say i have a thread defined something like this: class NoLooperThread extends Thread{ @Override public void run(){ …
j2emanue
  • 60,549
  • 65
  • 286
  • 456
0
votes
3 answers

Unable to achive synchronization in multithreading

I'm basically trying to implement a real life example of multiple people booking a single taxi online. Here in my code I have 3 classes- taxi,customer and server. There has to be multiple customers(threads) and a single taxi. But I'm unable to do…
Shivam Aggarwal
  • 734
  • 2
  • 9
  • 23
0
votes
1 answer

Android animation rotate stucks when calling additional methods

I want an imageView to be rotating, during my method "fireShowAction" collects some information from the "socket". This is a snippet of my code: 1st: create a button at "onActivityCreated()" method btnUpdate = (ImageView)…
prototype0815
  • 592
  • 2
  • 7
  • 24
0
votes
2 answers

Can someone show me how to properly use a single thread vs multiple threads?

I'm confused on how I would use a single thread to open and read multiple files compared to having a thread per file. Basically, I'm confused with the syntax and how I could establish lets say 50, 60, or even 100 different threads depending on how…
Sam
  • 23
  • 3
0
votes
0 answers

Calculation Method doing nothing every time except initialization (I think it has something to do with the threading)

The program is a Mandelbrot set renderer, and it opens initially with a correctly calculated and rendered image; this initialization is done with my recalculate() method. However, when my event handler makes a call to the recalculate() method, I…
Mat Jones
  • 936
  • 1
  • 10
  • 27
0
votes
2 answers

How to monitor a variable in another class and run a method when its value changes (java)

Im trying to build a graphic game (in java) that needs to move between worlds when the player reaches a specific point. Each world is represented by a class that extends GCanvas and the whole game is managed from the main class. I start when the…
Amit
  • 1
  • 2
0
votes
0 answers

Directory watch, locked files

I´m try to build a application which, by threads, are listening to directory for changes. Everything works fine, but there is a little bug. I´m very new to the whole threads-thing... So, this problem probably based on my ignorance... The program…
user2734182
  • 1,835
  • 4
  • 17
  • 22
0
votes
0 answers

Why did the definers of the Java Language Specification decide not to allow a Java Thread to restart?

While I was reading a book by Kathy Sierra and Bert Bates, I found a passage that says Once a thread has been started, it can never be started again. (page 716) Why did the definers of the Java Language Specification decide not to allow a Java…
Ascendant
  • 827
  • 2
  • 16
  • 34
0
votes
1 answer

Node CPU usage/load spiking

I have a number of nodes that are running JBoss 6 on it and an application hosted on it. Lately, I have seen that most/all of them have been have been complaining about high CPU usage and load and this results in the application slowing down. So…
Jason Stanley
  • 169
  • 1
  • 10
0
votes
2 answers

Executing similar tasks sequentially with ThreadPool

I want a ThreadPool to execute customer orders, multiple orders should be processed parallel, but for the same customer orders should be processed in a generated sequence. Which means if any thread already processing customerA order then no other…
ravthiru
  • 8,878
  • 2
  • 43
  • 52
0
votes
0 answers

Thread memory is not released

I have a issue like, I have written the DownloadAction(for download a document) in struts after that i am forwarding request to some jsp. Here the snippet. public class DownloadAction extends AbstractAction { public ActionForward…
0
votes
1 answer

synchronized on an Object seems like it's not synchronized

I run a program which contains the following classes (not only, but these are the relevant ones for the question) Under Results class I have a synchronized LinkedHashMap such as: private static Map
0
votes
0 answers

how to ensure thread-safe when using the semaphore

I want to add a synchronised section of code after first acquire the semaphore and I am not allowed to synchronised the function. So I wrote the following codes. Unfortunately, from the output, my program was blocked. Why is that? And how should I…
NUO
  • 247
  • 2
  • 3
  • 14
0
votes
1 answer

Creating different ImageView objects - different times

I have a basic Java problem in my app. I'm creating a program of bouncing balls: I have 10 Image Views of 10 different balls. I have a Ball class which uses its own thread (ball's physics). In MainActivity I create a new ball (first Image…
SHAI
  • 789
  • 3
  • 10
  • 43
0
votes
1 answer

Converting to ExecutorService

I have a consumer/producer program where: items to be processed (Strings) go into a BlockingQueue I instantiate a fixed number of threads that perform take() from that BlockingQueue and then process those Strings. The processing threads are…
Piero dS
  • 153
  • 1
  • 1
  • 5