0
votes
1answer
42 views

Why Thread.sleep is bad to use - Java

Apologies for this repeated question but I haven't found any satisfactory answers yet. Most of question had their own specific use case. Java - alternative to thread.sleep Is there any better or ...
1
vote
1answer
13 views

Fairness setting in semaphore class in Java 7

I am trying to understand the usefulness of fairness property in Semaphore class. Specifically to quote the javadoc mentions that "Generally, semaphores used to control resource access should be ...
0
votes
3answers
25 views

Java: Thread/task expiration after specified milliseconds

In Java is there a sane way to have a thread/task run continuously and then end after a specified run time (preferably without using several timers)? For instance, if I have a TimerTask, there ...
3
votes
3answers
64 views

Why multithread program in Java slow and yet doesn't use much CPU time?

My Java program uses java.util.concurrent.Executor to run multiple threads, each one starts a runnable class, in that class it reads from a comma delimited text file on C: drive and loops through the ...
0
votes
0answers
20 views

Concurrent execution of TimerTask or Runnable, etc

I have a Timertask that is designed to gather metrics at a specific interval. However it is possible that the period of the task execution is less than the time of task execution (occasionally if ...
0
votes
1answer
37 views

Java - Threading HttpUrlConnection calls

I have a custom service module where I pass up a JSON body, containing an array of IDs. I have to iterate through these IDs and make a separate web service call with each ID to obtain a response body, ...
0
votes
1answer
25 views

Executing 2 or more Runnables causes performance issues

I need to factor a 64-bit number (n = pq). So I implemented a method which searches consequentially all numbers in range of [1; sqrt(n)]. It took a 27 secs to execute on Android with 1,2 GHz ...
2
votes
2answers
35 views

Traversing and enumerating a directory with multi-threads

I am running a thread to traverse my local directory (no sub directory) and as soon as I am getting a text file, I am starting a new thread which will search a word in that file. What is wrong in the ...
3
votes
4answers
50 views

Thread variable after call start and run

I realized that this code: public class TestThread3 extends Thread { private int i; public void run() { i++; } public static void main(String[] args) { TestThread3 a ...
0
votes
2answers
23 views

Android Threads, Handlers, handleMessage: Updating UI thread from runnable threads within external class files

Firstly I am quite new to Android so please bare with me :) Background: I am trying to convert a Java (Non GUI) program to run on Android. For simplicity lets say this program has the following ...
-1
votes
2answers
57 views

Is it possible to have a function call as the body of a thread?

Is it possible to have a function executed in a different thread by just calling that function in the body of the thread I have defined? Thread background = new Thread(new Runnable() { public ...
0
votes
1answer
28 views

How to update MySql Database from threading in java

Hi i have a java program which fetch json data from one website and we store that json data in our local Mysql database. From the local Mysql database we are using those values for some calculations. ...
0
votes
2answers
29 views

How to configure ThreadPoolExecutor to limit number of threads

Before I get into details, I want to say that I have everything working using threads. I want to use ThreadPoolExecutor. I could not understand how ThreadPoolExecutor works in my case. I have an xml ...
0
votes
2answers
25 views

ScheduledThreadPoolExecutor - single task/thread running often or multiple threads running less often

I'm trying to set up a job that will run every x minutes/seconds/milliseconds/whatever and poll an Amazon SQS queue for messages to process. My question is what the best approach would be for this. ...
1
vote
3answers
63 views

unwanted output in multithreading..!

class mythread implements Runnable { Thread t1; String name = ""; public mythread(String thname) { name = thname; t1= new Thread(this, name); ...
0
votes
1answer
26 views

creating an array of blockingqueue

I am implementing multi-thread and want to be able to send/receive message to/from each thread from the main. So I am trying to setup a blocking queue for each thread with the following code: public ...
0
votes
1answer
28 views

Does fairness guarantee FIFO scheduling?

Directly from this website: But if we are specifying the fairness parameter as “true” while creating a new ReentrantLock object, it gives us the guaranty that the longest waiting thread will ...
1
vote
2answers
76 views

Illegical static declaration in inner class

import java.lang.*; class mythread implements Runnable { Thread t1; String name = ""; mythread(String thname){ name = thname; t1 = new Thread(this, name); ...
0
votes
2answers
30 views

“Routing” tasks inside threadpoolexecutor

I have class which implements Runnable public class MyRunnable implements Runnable { private long RID = <SOME_LONG_ID_VALUE>; public long getRID() { return this.RID; } public void ...
0
votes
0answers
12 views

LineUnavailableException thrown when getting microphone Input

I'm currently working on getting this basic sound input to output program working in Java. I've created a class that extends from a JFrame as seen below: Oh and sorry about how big it is! I tried ...
3
votes
2answers
70 views

Too many Garbage collection threads

I am developing an software with java, it creates a thread upon receiving an event (from sensors). the time-to-live of these threads are very small (< 1 second) The sensor sends maximal 10 ...
0
votes
1answer
45 views

Java Thread : Query regarding Thread waiting state

Suppose i have one synchronized block , and say 1000 threads access to that block simultaneously and one thread got access to sync block. Other 999 threads will go to waiting state till they are ...
2
votes
3answers
41 views

What is the best way to make bundles run parallel, threaded, in OSGI

I'm working with the OSGI framework to make an application that heavily relies on processing of packages of data. Every bundle processes a package and then sends it to the next. What I want is that ...
1
vote
4answers
71 views

java Pause code and wait for user input

I wrote my program in two parts, I wrote the actual functionality first, and then the GUI to display it all. I need to wait/pause for a user to click a "Done" button from another class(DisplayImages) ...
2
votes
4answers
24 views

CopyOnWriteArrayList iteration inconsistancy with multithreading?

I'm currently sending batches of Strings in CopyOnWrite ArrayLists with ExecutorService to be processed in parallel, where the Runnable task processing these lists need to iterate over the list and do ...
0
votes
2answers
23 views

org.hibernate.util.JDBCExceptionReporter] Duplicate entry X for key 'PRIMARY'

I am writing a back-end java code with active-mq in producer consumer model. When multiple consumers runs using and try to update in a table question the following exception is occured and the ...
0
votes
7answers
65 views

java.util.ConcurrentModificationException: Unexpected List modification while multithreading?

I'm using multithreading to process a List of Strings in batches, however I'm getting this error when the Runnable task is iterating over the List to process each String. For example the code roughly ...
0
votes
0answers
28 views

HTTP Requests on Seperate Threads

Problem: I am designing a multi-threaded application in which each thread makes http requests. Multiple threads can be running at once and if multiple http request are in progress at the same time, ...
0
votes
4answers
55 views

What character does a BufferedReader interpret as the end of the stream?

When reading from a socket using a BufferedReader it states that the readLine() method returns A String containing the contents of the line, not including any line-termination characters, or ...
0
votes
1answer
15 views

tracking tasks not completed in an executor framework

I am working on a multithreaded application and using ExecutorCompletionService for my purpose. So far the application has been running fine and there is no issue. However there is a particular ...
-1
votes
2answers
27 views

Server handling multiple client [on hold]

I'm using ServerSocket for creating a server. I must create a new thread for each client or is it possible&safe to use only the server's thread?
0
votes
1answer
72 views

Java threading issue, I am getting a null, while executing a async task

I am trying to implement a async return for a time consuming task. So task data is inserted in a Q, and return immediately. A bunch of 20 threads take tasks from that data queue. But the data in ...
0
votes
0answers
33 views

How to create bufferstrategy in a class which extends JPanel

I am beginner in Java and I am having difficulties creating bufferstaregy in a class which extends JPanel but not canvas. Can some one show how to add buffer strategy here. I wrote very simplified ...
0
votes
1answer
42 views

block a thread until it gets a specific signal from some other thread (java)

I have an java server application communicating with clients via sockets. Every client request is handled in a new thread. But for some requests I need to synchronize two clients. Example: Client ...
-5
votes
1answer
72 views

Sorting by multithreading [on hold]

I have create a program to split an array into two arrays, then sort them after that merge them back together. My program works perfectly when I invoke run() directly, but when I use start() I get a ...
0
votes
2answers
49 views

Updating Multiple Textbox Java GUI

Hi friends i am here again with another problem in same code. I have an activity or form in which there is one text box called time here. As suggested by experts from this forum i am using runnable to ...
0
votes
1answer
32 views

Java, Passing value to a constructor of class inplementing Callable

So, I have implemented the following simple class to parallelize the independent encryption processes: public class SelectionEncryptor implements Callable<BigInteger> { private ...
0
votes
1answer
40 views

Implementing multiple queue and single thread in Java

Using Java I need to implement the following architecture: There are multiple queues with jobs continuously coming in the queues. There is a single thread picking up jobs from the queues following a ...
2
votes
1answer
63 views

Repeatable start of thread

This code contains moveable pacman, who shoots little oval after pressing space button.So boolean variable is by default false.It becomes true after pressing space button, and oval is drawn.After ...
-1
votes
3answers
54 views

Java: How should I implement waiting so that Images render?

I'm not sure I've really asked the question correctly...and I'm not even sure if I've relevantly phrased the question or not..So, I apologize in advance...but I'm quite stuck on this issue and ...
0
votes
3answers
41 views

Handling sockets in java

I am creating a socket to a server in java and after the socket is connected it creates a new thread which can access the socket input and output stream and this thread then blocks and processes the ...
-1
votes
1answer
45 views

Java best way to multihread save/load large amounts of data [on hold]

For a game I am writing, the world is saved as chunks. Each chunk (when saved) is just under 200kb (they are very large chunks). Whenever a world is loaded 121 chunks need to be loaded. Each one only ...
1
vote
3answers
85 views

How to access arrays from multi-thread?

Simply speaking, my problem is as follows: I have an class named Test and it has 3 double arrays,named array1, array2,array3 respectively(assuming they have the same length).It has a major function ...
0
votes
1answer
53 views

What does the event dispatch thread actually do?

I have read a statement "What the event dispatch thread actually does is run an OS-level message loop to be notified of UI events, then dispatch those events to the appropriate Swing components." if ...
2
votes
2answers
46 views

What is the real value of Collections.synchronizedList/synchronizedMap?

I don't see any real value of using Collections.synchronizedList/synchronizedMap, and further more as per documentation we need to synchronize list/map during iteration, which is not good for ...
1
vote
3answers
71 views

Unit testing a parallel Java program

I'm trying to write a JUnit test. My problem is that my threads can't see the object I have created in the sequential bit of code (code before starting the threads). public class MyTest implements ...
0
votes
0answers
43 views

Lock using ReentrantLock in java

I'm trying to implement at playlist in java. The only problem is that populatePlaylist() is a bit slow and needs to be locked. I have written this code but it doesn't seem to work. private ...
2
votes
2answers
67 views

Java starting thread issue

Here's just part of my code, if you guys would need whole code, let me know.So my issue is, that this part if(shoot) thread.start();actually doesn't work as I'd like it to work.Using KeyListener ...
3
votes
2answers
25 views

Propagating “daemon”-status to all child-threads in Java

If I have a Thread object, I can call setDaemon(true) on it to mark that this thread should not prevent application shutdown if all other non-daemon threads have terminated. Is it possible to make ...
1
vote
3answers
78 views

Java- creating a new thread

I'm pretty much new to threads.I wanted to create some simple function working separately from main thread.But it doesn't seem to work.I'd just like to create new thread and do some stuff there ...

1 2 3 4 5 199
15 30 50 per page