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

Controlled execution of AsyncTaks

I have a for loop that creates several AsyncTasks. A large array of data exists and the for loop processes each data and calls the executor with that data. The AsyncTask does some intensive processing on that data and this code works perfectly fine…
0
votes
1 answer

IllegalThreadStateException: Thread already started on new Thread

I'm using HockeyApp to catch crash issues from internal testers and a single crash report with this trace came in: java.lang.IllegalThreadStateException: Thread already started at java.lang.Thread.checkNotStarted(Thread.java:849) at…
RobVoisey
  • 1,083
  • 15
  • 24
0
votes
0 answers

Graphing GUI freezes and doesn't load while I'm polling for data

I am creating a live graphing application, using a library called 'LiveGraph', which I stumbled upon. Essentially, the LiveGraph application is a GUI that keeps on reading from a text file with data, and updates the corresponding graph. Here is a…
stoneman
  • 25
  • 5
0
votes
1 answer

Why thread is use to invoke constructor of a class?

I came across one question when I gone through a JMS book. Below is the code. My question is related to thread so I removed the unnecessary JMS code. public class MessageConsumer implements MessageListener{ public MessageConsumer(){ …
Angom
  • 721
  • 1
  • 11
  • 27
0
votes
2 answers

How to speed up Android app loading 140,000-item ArrayList from an Asset

I have a Java program that I just turned into a slooooooow-to-load Android app. The problem: it deals with a 140,000-word "dictionary" (stored in an Asset file) in which to look for words matching "Windows wildcard" patterns: E.g., S???CK* would…
DSlomer64
  • 4,234
  • 4
  • 53
  • 88
0
votes
2 answers

How do I call a method in a specific socket thread using "implements Runnable"?

I have a working Java Server (Although a tad rough around the edges) which contains 3 main classes. The first class runs the server and gets the socket to listen on a port and passes new connections to a client handler. The second class is a…
0
votes
2 answers

How can I interrupt a thread created from within a method?

I know that you can interrupt a thread created from say a runnable class, but how can I interrupt this thread I created from a method? Using a volatile boolean isn't working for me, so I assume either there is a better way to do this, or I need to…
0
votes
1 answer

Call function on fix time interval using Thread

I want to call my function on specific time interval. For now my time interval set fixed as 1 minute. I have following code example: Timer.java import java.util.Date; import java.util.logging.Level; import java.util.logging.Logger; public class…
Piyush Chaudhari
  • 962
  • 3
  • 19
  • 41
0
votes
0 answers

Task Scheduling using threads in java(Edited)

I am currently working on a DB integrated daily file transfer scheduling form application for operational business use. In order to be able to control and have access to specific schedules, I have decided to create a thread for each schedule so that…
0
votes
0 answers

What does Post invalidate method do in Thread class

This is my code: package com.example.analogclock; import android.view.View; public class MyThread implements Runnable { private View view; public MyThread(View v){ view = v; } public void run() { …
0
votes
1 answer

Where does this loop go wrong?

I am currently working on a text based rpg in java. Each time the player walks a certain number of steps, a random battle is supposed to occur. Each time I run the battle system, the program goes into a forever loop and the screen just freezes. How…
Anonymous827364
  • 247
  • 1
  • 2
  • 7
0
votes
2 answers

Stop thread in 30 seconds and retry

I have a Restful Service that is calling an external application. This application is making my service hang. So when a user calls my service, it may take an hour due to this external application. The external application should only take a few…
Chris Bolton
  • 2,162
  • 4
  • 36
  • 75
0
votes
0 answers

How to spawn multiple threads for upload without waiting

I have the following class which is responsible to fetch non synced receipts from the receipts table and upload them to the server, the following function as of now just iterates through the cursor result set: public class MidnightUpload { …
User3
  • 2,465
  • 8
  • 41
  • 84
0
votes
1 answer

How do I return a String from a Thread or get a string from a Thread?

I need to get a String value from a Thread, but I don't get it! Global variables don't work! Can you help me please? This is my code. I need to use the dataString: public class Deserializable { public void execute() { new Thread() { …
0
votes
4 answers

How do I get a string from a thread or return a String form a Thread?

Im using a webservice that get a data and stores in a String. I need to use this String but I cant take it. Global variables don't work in Threads. I'm using a traditional Thread new Thread() { public void run() {.