Amicuk Programming Answers

How to know if a thread is busy?

-0001-11-30   Views:0


I have a main class and a Thread class that is a client. I need this feature: client receive a data and pass it to main class; main class, by its methods, process this data; during processing, client could receive a new data, but if main class is sti

I have a main class and a Thread class that is a client.
I need this feature: client receive a data and pass it to main class; main class, by its methods, process this data; during processing, client could receive a new data, but if main class is still processing, client must reject.
The question is: how does the client knows if the main class is still elaborating?

The replay answer
In a thread I have put this method:
public synchronized void setIsProcessing(boolean
ean b) {
isProcessing = b;
then in a while I have:
synchronized (this) {}
if (!isProcessing) ....
else .....
I'm calling setIsProcessing from main class when I'm
starting doing anything, but if in a thread arrive
another things, it seems it queues it, and sends to
the main class when main has finished (it seems
isProcessing is never setting to true).
Why?Using the keyword synchronized in a non-static method is implicitly the same as using synchronized(this). If within the second bit of code you have an infinite loop that doesn't release the monitor then setIsProcessing() can never actually be executed by another thread as that requires acquiring the same monitor that you're not releasing.
::The main practical reason for "implements Runnable"
::of "extends Thread" is that Java doens't support
multiple inheritance
:: of classes. So if you extend thread, you can't
extend anything else
:: but if you implement Runnable, yo can extend some
other class.
So, this is the reason of "implements"? Sorry for
this "academic" question ..If by that you mean as a solution to the problems of a single inheritance model then yes.

Go to See the other 15 answers

Stuck Thread - JMS Business proxy Service (ALSB 2.5)

Category:DefaultRelease time:-0001-11-30Views:130

Hi All, We are having a jms proxy service which uses a JMS Business Service to send messages to a jms queue on weblogic 8.1 sp6. The alsb domain runs on weblogic 9.2.The jms proxy service is made single threaded by configuring a suitable work manager[More]

Main thread is busy, cannot receive callbacks

Category:DefaultRelease time:-0001-11-30Views:130

Hi, I'm using the measurement studio activeX control to program my application. (NI-DAQ 6071E) My main thread is always busy because there's a lot of calculating and graphing. I'm using the CWAI control to do continuous caputuring. When the program i[More]

How to know if a thread is busy?

Category:DefaultRelease time:-0001-11-30Views:130

I have a main class and a Thread class that is a client. I need this feature: client receive a data and pass it to main class; main class, by its methods, process this data; during processing, client could receive a new data, but if main class is sti[More]

Best way for a thread to wait without busy-waiting

Category:DefaultRelease time:-0001-11-30Views:130

Hi! I have a thread that has nothing to do but to monitor the status of a variable public static boolean askToClose. This variable is set by other threads to indicate that this thread should stop now. But I don't want the thread to busy-wait like in[More]

Thread count tuning

Category:DefaultRelease time:2015-10-11Views:130

Hi! We are running a weblogic 5.1 server for jsp/servlet/ejb behind an apache web server, via the wls/apache bridge. As the number of users increased we expereienced slow response times. We checked thread dumps from peak hours and saw that all servle[More]

Applet UpCall from JS Event - Which Thread? Options

Category:DefaultRelease time:-0001-11-30Views:130

Hi, With many direct references to the second lovely colour diagram on this page: - I completely understand the hour-glass pause on the single-JS-thread preservation architectur[More]

How to terminate/destroy a user thread running in background?

Category:DefaultRelease time:-0001-11-30Views:130

Hi All! I m using t.destroy() to stop a background running thread, as t.stop() is depricated in Java 2. I implement Runnable in the background thread. On calling t.destroy() NoSuchMethodException; don't know whats the problem there?I still don't see[More]

Business One Trial???

Category:DefaultRelease time:-0001-11-30Views:130

Where can I find a trial version download of Business One for windows so I can learn it before implementation??? Thanks...Hi, Check thread => SAP Business One Trial Version May it will help you. Thanks and Regards, Faisal Edited by: Faisal Altaf on D[More]

Difference between business area balance sheet and profit centre accounting

Category:DefaultRelease time:-0001-11-30Views:130

Hi all, I want to know what are the differences between business area balance sheet and profit centre accounting. Please tell the merits and demerits of both. If, I want to get plant-wise profitability of a company then which method is more recommend[More]

Do we need a SAP Business One & Business Objects Forum?

Category:DefaultRelease time:-0001-11-30Views:130

Hi all, We have made the Crystal Reports Add-on for SAP Business One available in the [Knowledge Center|] For all discussions arround SAP Business On[More]

Business Place by default in MIRO based on PO

Category:DefaultRelease time:-0001-11-30Views:130

Hi, I have a requirement where I need to default a value in the business place (BUPLA) field in MIRO based on the site(plant) in the PO. please help me how to achieve this. thanks in advance, kumarHi Kumar, i feel that you might need ABAP help to ach[More]

when we print the payment proposal via F110 Edit>proposa>proposal list the bank details from the vendor master used to appear, however they have suddenly disappeared we use standard SAP program RFZALI20 thanksHi, I am not that much sure but this can [More]
Hard Drive Replacement: I need to replace, and hopefully, upgrade a hard drive in a HP Pavilion dv4-1318tu laptop.  Can someone suggest a larger and hopefully faster drive? Kindly tell the specifications of HDD which is suitable to my laptop. Hi, The [More]
I want to connect an incremental encoder with A, B and Z to a PCI 6014 card. I found some VI's for counting A and B (DAQmx->Counter->Count Digital Events; DAQmx->Counter->Measure Posititon) . However I can't figure out what to do with the Z. I [More]
Hello, I am new to this forum and I couldn't find one for the DVD Player specific so I chose this one. Please direct me to a different one if my eyes were misleading me. I have a new Macbook. Just over three month now and I attempted to watch a movie [More]
I handed my phone to a friend to take a short video of her daughter and on importing found the video was rotated. Is there a way of rotating the video to correct this in iMovie?  TIAYes you can.  Assuming you are using iMovie 10. see: [More]
The free Koyote Soft HD Converter is a popular choice for converting AVCHD to MPEG2 HD for use in Premiere Elements. My experiences with that software have been with the 1.4 version of it. One of the first persons who brought this software to my atte [More]
It seems that everytime i call, the techs dont know what im talking about. So i'm gonna ask you guys, how do i open the NAT on my westell 7500 modem/router#1 For what? A game console (for example an xbox), a Web Server, a FTP Server? #2 If game conso [More]
I'm attempting to catch unhandled exceptions in my app on windows 8.1 I've noticed that in my App_UnhandledException handler, that the UnhandledExceptionArgs.Exception.StackTrace is valid on entry. However, I take the same Exception object, and pass [More]
Hy all. I have two problems whith JSF and Seam. I've define several areas on an image to choose points of impact in an accident Code is like this: <center><img src="myImage.jpg" usemap="#ImpactLateralGauche" border="0&quo [More]
Hi, I saved one file as .tif and now after using RAW to process images, opening in CS3, trying to save, there are no options either .jpg or .pds. I had to open two previously saved .jpg files, before I had the full range of choices. Is this normal? T [More]