Tagged Questions
0
votes
1answer
37 views
Java Threading- Am i writing thread-safe code?
I'm currently trying to get into parallel processing, so to do this, I'm writing a program that processes an image, giving information about its color values overall- I am doing some tests on this one ...
0
votes
1answer
8 views
Design proposal needed: Enabling menu item from outside JFrame
My Java application mainly lifes within a JFrame object. Its "File" menu has 2 entries "Open" and
"Close". "Close" menu item is disabled. It will be enabled by fileOpenActionPerformed once it
finished ...
2
votes
3answers
60 views
Java Deadlock code explanation
Could someone please explain why the following code results in deadlock.
My understanding is that when alphonse(thread) run then it acquires lock on friend obj because it invokes bow() method but how ...
0
votes
3answers
33 views
Thread safe high-performance matrix-like container in Java for cellular automation?
I'm doing a cellular automatan that I'm running as an instance of a class with a specific thread provided for it. For the new functionality, namely adding live cells through mouse input while the ...
0
votes
3answers
24 views
How to end non-daemon thread when the application exits?
i have a main thread in my app and inside this main thread i create another thread, let's say it is named named "WorkerThread".
The WorkerThread has an infinite loop that does some database search and ...
0
votes
1answer
19 views
Synchronize across two ScheduledExecutorService task pools
Trying to figure out how to do concurrency properly in Java. I have two groups of tasks. Tasks within a group do not interfere with one other, and so may be run concurrently without problems. However, ...
-4
votes
1answer
16 views
How to debug multithreadded web application
To simulate a concurrency issue in local environment, I want to hit two requests and debug them simultaneously.How can we debug multiple threads hitting a debug point simultaneously and then control ...
0
votes
1answer
35 views
FutureTask with Runnable and Results
I googled on this , but still could not get a solid understanding. I could not find any particular example that uses FutureTask(Runnable runnable, V result) constructor
Java doc says
Future ...
0
votes
2answers
55 views
How to synchronize two thread that are not mine
I'm in difficult situation in which I need to (because of the bug) synchronize two threads, but I'm not creator of those two threads (it's part of software I'm using).
There are two threads in my ...
0
votes
2answers
41 views
Updating an Object from different threads
I am calling 4 threads separately at the same time. These threads are making http calls and are fetching data from separate links.
Now, I created a class, instantiated a single object of that class ...
0
votes
1answer
28 views
BlockingQueue on main Service thread
My android app has a long running background service, which I also understand runs in the application's main thread and for that reason, any time consuming or blocking task should be moved to a ...
0
votes
0answers
13 views
Grails StaleObjectStateException in lock() method
I'm receiving a StaleObjectStateException while I'm trying to lock a domain object inside of a transactional service (grails 2.3.8):
@Transactional
class AnalyticsService {
boolean ...
1
vote
1answer
50 views
Real ThreadLocal usage in Java
Just began studying Java ThreadLocal type. I could understand those typical examples of it, like defining a class, who has an instance field that is declared to be ThreadLocal; then after creation of ...
0
votes
1answer
23 views
More than one thread inside synchronized methods? [duplicate]
As I red somewhere, when we have synchronized methods, only one thread can use any of those method at the same time. The problem is that I have small peace of code that looks to break this rule, and I ...
0
votes
1answer
13 views
SWT Threading: GUI not responding even after calling thread.stop()
say i have this code inside a SWT button :
Button btn = new Button(shell, SWT.NONE);
btn.addSelectionListener(new SelectionAdapter() {
//... some code...
Thread t = new Thread(){
...
1
vote
4answers
63 views
Why to use wait method on strings or other objects?
I have following piece of code:
synchronized void myMethod() {
String s="aaa";
try {
s.wait();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
The code throws exception ...
0
votes
1answer
33 views
Why does the following executor service java Thread program doesn't get all 1000 results at same time?
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import ...
0
votes
1answer
29 views
Tread getting lost lock and give chance to execute another thread
here i have share an object with 2 thread and providing lock on object by print() but after some loop it losing lock and execute the second thread and it will change the value of breakLoop and first ...
1
vote
2answers
58 views
Check what thread a method is being called from [duplicate]
I have a method that I only want to have called when not on the main thread (does heavy work) and if it is called from the main thread I would throw a runtime exception, similar to what happens when ...
0
votes
3answers
66 views
thread safety on single instance method in java
If I have one instance of an object A and it has an instance method foo() with only variables created and used in that method is that method thread safe even if the same instance is accessed by many ...
0
votes
2answers
67 views
Recursive function in Java - thread safe collection
Lets suppose I have a xml documents in which i can find links to the other documents of the same type which can also have a links to another one documents. At starting point I have list of documents ...
0
votes
2answers
50 views
Android:Is my Async Method working?
I decided that in order to speed up my application and avoid crashing i would run my method PetrolPriceString on a background thread through the AsyncTask method. However even though my application ...
0
votes
1answer
27 views
Thread communication: wait()/notifyAll()
I'm currently reading about Threads in Java and playing around with the wait() and notifyAll() methods. I'm trying to understand this by coding a practical example, but I'm not getting the desired ...
0
votes
0answers
54 views
Send email on status change
I have a project which currently only does methods when I run the site. Now I need to implement a thread which checks the DB/the website for status-changes so I can send out a mail if something ...
0
votes
2answers
80 views
How can only one servlet instance exist in multiple threads? [on hold]
Usually, there is only one instance of a specific servlet in the container. This servlet gets reused for every request. However, by default, every servlet request runs in a different thread. How can, ...
0
votes
0answers
39 views
How to make TransformerFactory thread safe?
I have the following code to transform the xml file to html file.This is accessed by many threads.The transform method just appends the content every time.That is the first threads content is retained ...
1
vote
2answers
46 views
Update UI widget from onPostExecute() of AsyncTask in another project
So, I want to display an image in an ImageView that is downloaded from a website and saved on the device's file system. The downloading of the image is done by calling a method in another class (in ...
0
votes
1answer
17 views
Share one set of read-only Table data across many users/sessions/UIs in Vaadin
I have a a set of read-only data to be displayed as a Table in instances of the same Layout across many user sessions. Rather than replicate the data for each user, I'd like to have only a single ...
1
vote
1answer
24 views
Reusing ThreadPoolExecutor vs Creating and Disposing Ad Hoc?
I am building a multithreaded process that has a couple stages, each stage iterating through an unknown number of objects (hundreds of thousands from a buffered query resultset or text file). Each ...
0
votes
1answer
46 views
NullPointerException when using TextArea.append()
I realize there is an nearly identical question in title. The question does not seem to be relevant to my particular issues.
I'm using the JavaFX scene builder to create my UI, (which includes the ...
1
vote
2answers
47 views
JAVA: What part of code block does synchronized key-word block? and explain this deadlock [duplicate]
I have to questions:
1. What part of the code of a synchronized method, the synchronization block?
for example:
public class example{
public synchronized void f1(){
//some code....
f2();
...
0
votes
1answer
23 views
Is calling external programs from Java the same as threading?
I just got into executing batch programs from Java. I was trying to make a converter program poll a directory so that the files would automatically be converted by ffmpeg and sent to an output ...
0
votes
1answer
53 views
How to stop the printing in thread A from thread B?
I have written some Java code, which will call a C interrupt handler.
In Java thread A, I use waitFor() to wait the interrupt coming and then execute reboot.
In Java thread B, I will loop printing a ...
0
votes
1answer
44 views
IllegalMonitorStateException: object not locked by thread before notify()
Yes, I have seen previous questions on similar topics, but they don't seem to help me. If there is a duplicate, please point me to the question, thanks
I have two problems here, the first one is the ...
0
votes
0answers
25 views
Listener doesn't work when changing Panel
i've got a problem with my program. I'm finishing to develop Pacman for my exam but I've a trouble when I change Panel from "menu" to "game" Panel.
Precisely in the main frame I've added two Panel : ...
0
votes
0answers
30 views
Android - Threading/AsyncTask - while loop
I'm trying to make a game (Tic-Tac-Toe) where the player waits for the comp to move and vice versa. This goes on until someone wins.
The app crashes and the waiting isn't really working.
Here's my ...
0
votes
1answer
15 views
InnoDB database locking blocks threads
I have a really weird issue with a project I'm working with. I would appreciate if someone could point me to a right direction here.
// Setup
There are multiple web servers and a loadbalancer is in ...
-1
votes
1answer
31 views
Java: Consoled Multithreaded chat program
This is a simple multithreaded chat program I'm doing. Everything works fine except the output formattting. AFter the client connects to the server, then the chat initiates. But on both the consoles, ...
1
vote
1answer
74 views
Double-checked locking as an anti-pattern [duplicate]
There's a common belief and multiple sources (including wiki) that claim this idiom to be an anti-pattern.
What are the arguments against using it in production code given the correct implementation ...
0
votes
0answers
30 views
Prevent concurrent execution of related tasks in a thread pool or executor service
I have a queue of Runnables to execute that I would like to process using a thread pool. However, some of the tasks in the queue are related to each other (could be implemented by a common hashcode() ...
-4
votes
2answers
48 views
Multithreading program producing different ouptut
I'm running a multi threaded program and the problem I have is that it produces different output each time it's run. Here's my code.
package com.mypackage;
public class TryThreads extends Thread{
...
0
votes
1answer
34 views
How to update UI once background task is over in ZK?
I need a solution for a below problem:
I have a long running task which takes around 20-30 seconds to
complete.
This task is perfomed once user click on button on page.
Once task is over I need to ...
1
vote
1answer
42 views
Ideas on concurrent datastructure
I am not sure if i can put my question in the clearest fashion but i will try my best.
Lets say i am retrieving some information from a third party api. The retrieved information will be huge in ...
0
votes
0answers
16 views
Can Android Bluetooth connect to paired devices while listening?
Hey I am writing an a Bluetooth application, and I want the users be able to hit a button, and than discover other devices that are also running the application and than connect to one of the devices. ...
-1
votes
2answers
40 views
How to make a loop run independently in java [on hold]
I know in javascript there is a loop timer thing you can do to make a loop run regardless of what else is going on, I was wondering is there anyway to do this in java?
This is so I can have multiple ...
0
votes
0answers
13 views
Virgo error: no class definition found
The business logic in my code references a POJO TableIdSelector. When the business logic attempts to declare and initialize this TableIdSelector, the below error occurs.
This does not happen on every ...
0
votes
1answer
40 views
Android: Asynch Thread for Method
Ive realised that in order for a part of my application to work i may need to run it on a separate thread. After this my options seemed to be Asynch and Threads and i think Asynch seems the better ...
0
votes
1answer
32 views
Creating a New Instance causes a Crash in the Thread
Hello StackOverFlow Community! I have an issue with a line of code in one of my android, java apps I am currently building.
During the starting of the app, I run (amongst other code) the following ...
-1
votes
3answers
47 views
Threads freezing screen
All this is in the same class and onCreate method:
String arrayExtra[] = {"1"};
for(int x = 0; x < arrayExtra.length; x++){
Thread thread = new Thread(new Runnable(){
@Override
public void ...
1
vote
0answers
41 views
What happen if we want to interrupt the thread by setting the current by substituting equal to null [duplicate]
What Would happen if we interrupt a thread by making it's object reference equal to null
does the thread stack vanish or it still completes its whole processing and safely exists from the run method
...