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

I want to show gif image show on screen even when app is closed

With a mouse click, you implement two things: Sound is playing The GIF image is showing I'm trying to show the GIF on the screen even when I close the app I'm using the services but because the sound keeps playing while the GIF image appears, I…
-1
votes
1 answer

Multiple threads in for loop

I have a method I need to call for each element in a list, then return this list to the caller in another class. I want to create a Thread for each element but am struggling to get my head around how to do this. public List
arsenal88
  • 1,040
  • 2
  • 15
  • 32
-1
votes
1 answer

How to send mail within a servlet using threads or executor service?

I want to send mail based on if a condition ServletMail.java //somecodes //this code should code should be executed in background(by threads or something) if(cond1){ sendmail(firstcond) } else{ sendmail(secondcond) } //requestdispatcher
-1
votes
1 answer

Are annotations instance specific in java?

If I had two instances of a class instantiated in separate threads with the same annotation. And both threads were to modify the contents of the annotation for their class. Will the contents of the annotation be different for each instance or the…
blablabla
  • 304
  • 1
  • 8
  • 18
-1
votes
1 answer

How to achieve in java threads to check connection exists or not?

i have a scenario where in before i write any data to the RabbitMq queue i should check whether queue is alive or not. If not i should save the data into the localDb but and my thread code should be keep on pooling into the connection status to know…
Prash
  • 544
  • 8
  • 24
-1
votes
2 answers

How do I execute an async piece of code after another async piece of code has finished executing in java (sequentially)?

I have the following pieces of code: 1) int operationCnt = 10; for (int i = 0; i < operationCnt; i++) { // for every instruction final int curOperation = i; post(new Runnable() { @Override public void run() { //…
SudoPlz
  • 20,996
  • 12
  • 82
  • 123
-1
votes
1 answer

Binding instance of a class with thread

I'm creating client-server based application on Java and I've faced a problem related to threads. So basically, I've a GUI with list of instances of the same class with different ids for each item. When user clicks to one of them, there pop-ups a…
-1
votes
1 answer

InterruptedException; must be caught or declared to be thrown

I keep getting the following error: PrintServerV1.java:63: error: unreported exception InterruptedException; must be caught or declared to be thrown server.printRequest("homework7.txt"); ^ PrintServerV1.java:64:…
Pape Traore
  • 83
  • 2
  • 9
-1
votes
1 answer

Creates new Thread with parameters

In the class CameraMessageFrameWorker i want to create a new Thread to handle some messages. The consructor of these class get the PartialMessageFrame. I copy these PartialMessageFrame to the new private Variable messageFrame. With this variable i…
Dave
  • 19
  • 5
-1
votes
1 answer

How to find max element in an array using threads?

I've a piece of code that I've been working on in order to find max element in an array using threads. I've successfully done it to sum the element of an array but I've faced few problems figuring how to find the max. Also, I didn't know how to use…
Red John
  • 105
  • 3
  • 11
-1
votes
2 answers

Call another JFrame window from current window and exchange data

I have 2 Swing developed applications. 1) Pay screen, in which, user id and 'pay' buttons will be there. 2) Another screen will have 'Match' button which checks for validity of user and returns respective user's password. My main screen is 'Pay'…
sai kiran
  • 1
  • 3
-1
votes
1 answer

If thread-safe, any chances to make more concurrent

The class AnagramGameDefault simulates an anagram game. The submitScore() should recalculate the positions, the one with highest score has position 1, there can be several players on the same position. The getLeaderBoard() fetches the entry for a…
Kaliyug Antagonist
  • 3,512
  • 9
  • 51
  • 103
-1
votes
2 answers

Multithreading for array in Java

So, the scenario is like: //Some code... public Map someFunction() { for (final UserDetail user : userDetailList) { // the following (below) code runs in background thread // long running task new…
Sumit Jha
  • 2,095
  • 2
  • 21
  • 36
-1
votes
1 answer

Why isn't the run method executed?

I'm trying to create a square that can move by pressing keys. When I Compiled & Ran the code it wouldn't move. So I began debugging (as well as I'm capable of). The problem seems to be that the run() function isn't being called. Why is this ? My…
-1
votes
1 answer

Thread is not working properly (synchronization)

When I run this code, the output is "something is added" and then infinite loop ... My program should print: something is added something is printed I don't understand why the program can not exit while loop import java.util.LinkedList; public class…
AndroidDev
  • 39
  • 1
  • 7