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]

I have a problem with my Mac Book Pro. Sometimes i have a Kernel Panic on my Screen. I have loged this Protocoll: Can anyone help me with this Problem? What is the cause of these Kernel Panic. Thanks a lot to all members here! Interval Since Last Pan [More]
Hi , When I send a request to Report Server via WEB DB listener for PDF output report, it is generating 2 requests while opening the PDF output in the browser. If you make PDF browser integration off, it opens in Acrobat Reader properly with single r [More]
I still haven't adapted comfortably to iPhoto '08, because it's hard to change one of my iPhoto habits. Previously, after selecting a photo to edit, I'd click DONE and then go straight to File>Export or File>Print to output the edited photo. With iP [More]
Is there any way I can add a second external screen to my PBG4? I currently have a 20-inch Flat Plane Array attached to the DVI port of my G4 PowerBook, giving me effectively two screens: the PB's own and the external. Can I attach a third? I have he [More]
I want to set my font size to 14 permanently rather than change it every time I write and e-mail.Duplicate Thread LOCK please - Continue here: * other 2 answers [More]
So I am having a very strange problem. I have been using the Situations App (formerly Nokia Situations) to automatically put my phone into offline mode, and power saving mode over night. 9pm to 6:30am. Recently the phone as started refusing to leave [More]
I am new to the iMovie program. I have only been using it for about 2 months and have a kind of goofy question. When I import my movies from my camera and begin editing, the footage begins to play like it should. Then after a few seconds it starts to [More]
please help I need sound driver for hp dv8225nr that works with windows 7 I have tried realtec and conexant drivers and no results.Hi, Uninstall all drivers for audio and after that install this file: Conexant High Definition Audio Driver here  Let u [More]
I assumed that POP includes the pencil drawing Application?You can definitely use PS Touch as a type of sketchpad or notepad but its features in that regard are kind of paltry compared to, say, Sketchbook Pro or ArtRage. You're pretty much limited to [More]
My Hp Deskjet 6840 is networked to 2 G4 and 1 G3. I can print an entire layout at one time from an older G4 but can't from my Power Mac G4. It spools all 64 pages (Indesign CS2) then the program crashes. I am having this problem with other CS2 progra [More]