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

main method terminates when I instantiate a new thread

I am programming a top-down shooter game, and I want to open a new window between each level of the game. After each level, if a certain criteria is met then the following class is implemented: import java.util.*; import javax.swing.*; import…
-1
votes
1 answer

Thread execution

I have a web application that checks the user accounts from the database to determine their source. I want to make sure that the thread that goes to check the database runs first without any scheduling algorithm of WebSphere server. More…
-1
votes
1 answer

Java thread is consuming more time when the input increases

I have written a Java program to scrap through huge log files. For parallel processing of files, I am using thread concept. Below is the source code for the same. ExecutorService threadPool = Executors.newFixedThreadPool(8); for(int i=0; i <…
Madhu Velayudhan
  • 59
  • 1
  • 2
  • 8
-1
votes
1 answer

How to wait client in multi-threading

I have TCP client/server. Client is running two thread C1 and C2. And server is running three threads S1, S2, and S3 threads. C2 should receive results after server finishes S3. I have problem in the last step. The client and server look like this.…
peter
  • 17
  • 3
-1
votes
1 answer

setText() not reflecting changes when called from another thread

I am a beginner in javaFX and am stuck in this one area. Any help will be appreciated a lot. This is sample app I have made for clear understanding using scene builder. There is a text area and a button.I want to set data into the text area on the…
NiyatiShah
  • 41
  • 2
-1
votes
2 answers

How to run two thread periodically?

I am asked to make a Player class ( that implements runnable ) in which I implement a run method which generates a random number and waits for the method getchoice and a getchoice method which return the generated number and notifies run . then a…
Domarius
  • 19
  • 7
-1
votes
2 answers

Multi Threading banking simulation

At this moment I'm playing around with Multi Threading in java and I'm not sure how this works.. I feel like I understood this in a simple example I've seen on the internet but somehow I can't understand how this works in a banking simulation app I…
Ovidiu G
  • 1,253
  • 5
  • 25
  • 47
-1
votes
3 answers

Getting exception ArrayOutOfBounds

I'm new to java program. While executing a program related to threads I got an exception ArrayOutOfBounds. Whats the mistake I made. Please review my program and reply back soon. I'm stuck with this program. import java.util.Scanner public class…
Sukanth K
  • 11
  • 6
-1
votes
1 answer

Placement of Thread Content. How do you know what goes inside of the thread, and what doesn't?

Overall, this is a homework assignment for a graduate level class, so much of the assignment is omitted, but I think I gave enough to make my question clear. In short, the prompt is below. Prompt: Assume that you have a set of files…
Xenorosth
  • 97
  • 1
  • 9
-1
votes
1 answer

Sorting a list with Threads in Java

I have a list of words, 1000 words, I should list them from the most occurring to the least occurring. Like: Dog, 100 times Cat, 50 times Fish, 40 times Monkey, 10 times Bird, 10 times Camel, 10 times . . . Lion, 1 times Tiger, 1…
Anarkie
  • 657
  • 3
  • 19
  • 46
-1
votes
1 answer

Thread null-pointer exception Java netbeans

I'm trying to open a thread in Java, but for some reason I get an exception every time. my syntax : Thread receiveThread2; receiveThread2 = new Thread(() -> { try { receiveMessageNoLoop(); } catch (IOException ex) { …
Zohar Argov
  • 143
  • 1
  • 1
  • 11
-1
votes
5 answers

i want to open new activity in Array Adapter tell me how its possible

This is my code which is i'm working but the startActivity function is not working here and the click Listener is working. Please help me how is this possible. This is my main Thread code: restaurant_Array_list = new…
Yaseen Ahmad
  • 1,807
  • 5
  • 25
  • 43
-1
votes
1 answer

Rejected from ThreadPoolExecutor, multiple bound services

In a FOR loop within one of my bound services, I make another call to another bound service. I get the error "rejected from java.util.concurrent.ThreadPoolExecutor". I know this is because there are not enough threads to execute my tasks. I'm a bit…
-1
votes
2 answers

Java DatagramSocket Diferrent Thread for every client request

I'm working on a project in Java where clients send via DatagramSocket a basic calculation (eg 5+6) and the Server needs to reply with the result. The goal is to have a different thread calculating each different client request. So far I have this…
V. Georga
  • 9
  • 4
-1
votes
1 answer

Using Threads in Java class invoked by Worklight Adapter

We are developing an extension to an existing worklight (6.2) adapter to add some background stuff execution that is not mandatory to provide a response to the client invoking the original adapter. We thought to implement a new HTTP adapter backed…