Why Can't You Set The Value Of A Boolean Wrapper?

I don't see any methods in the Boolean class that would allow you to set the value of the underlying primitive. It seems that once it's created, that's it.
My reason for wanting to do this is that I have some synchronized code which is synchronizing on the value of boolean flag. Since you cannot synchronize on a primitive type, I decided to wrap it in a Boolean object....
Do I have to create my own custom class for this? Not that it would be hard, but it just seems like I shouldn't have to.
Thanks,
John
PS: If the above wasn't clear, the synchronized code looks like this:
//client code
synchronized (myBooleanFlag) {
  while (!myBooleanFlag.booleanValue())
    myBooleanFlag.wait();
//code which changes the flag
synchronized (myBooleanFlag) {
  myBooleanFlag.setValue(true); //WAIT!! There's no method to do this
  myBooleanFlag.notifyAll();

Hi,
You usually write it like this:
Object variableLock = new Object();
boolean variable = false;
synchronized (variableLock) {
variable = true;
}So, you don't have to synchronize on the value that
you want to change, just make all competing code
synchronize on the same (guard) object.Yes. That's what I want. Once again, Kaj saves the day!
Thanks,
John

Similar Messages

  • Why can't you set the inital view in preferences instead of on a document by document basis?

    You can set the initial view on the document level in document properties to display Bookmarks Panel and Page and that's the view you will receive the next time that document is open.
    There has to be a way to use a plug-in or something that will open all documents using that initial view, rather than having to set it each time.
    Thank you!
    Richard    

    Hi
    The 'Document properties' window is set to make changes to a particular document. In order to set common settings for all the PDFs, please make changes in the 'Page display' option:
    For MAC: File > Preference > Page display
    For Windows: Edit > Preferences > Page display
    Another point that you can make use of is: Whenever you close any PDF, Acrobat saves the last view settings and tries open the next PDF in the same view as it was closed.

  • Why can't you set iCal alarm to email on iOS?

    I set iCal on OSX to email me ~12hrs before events, then alert me again 1hr and 30min before. Why can't you set email alerts on iCal for iOS and why are the alerts limited to only two? I feel like the features on iCal for iOS and OSX should be similar but they are not.

    Hi Susan588,
    This article has instructions for disabling the parallax feature, which will allow wallpaper to be resized again:
    iOS 7: How to reduce screen motion
    http://support.apple.com/kb/HT5595
    Cheers,
    - Ari

  • Why can't I set the Date format in English for Malaysia Region for my iPhone and iPad?

    Why can't I set the Date format in English for Malaysia Region for my iPhone and iPad?

    Apple should change the settings to Malaysia -> Malay / English / Chinese / Tamil

  • Why can't you fix the theme in iPhone so it's black for exampel? It would be much nice!!! :)

    Why can't you fix the theme in iPhone so it's black for exampel? It would be much nice!!! :)

    http://www.google.se/imgres?um=1&hl=sv&sa=N&biw=1280&bih=709&tbm=isch&tbnid=xQZ9 2n7EiwlMEM:&imgrefurl=http://iphoneroot.com/t9-for-iphone-cydia/&docid=u4eAIeebp mV7WM&imgurl=http://iphoneroot.com/wp-content/uploads/2009/02/t9.png&w=320&h=480 &ei=2B_OT-vTAqn14QSmtoixDA&zoom=1&iact=rc&dur=462&sig=101681684250595658866&page =1&tbnh=162&tbnw=108&start=0&ndsp=19&ved=1t:429,r:1,s:0,i:74&tx=64&ty=29
    i want it to look like that, how do i fix that?

  • Why can't you use the ellipsis 7 as a phone since verizon assigns it a phone number

    Why can't you use the ellipsis 7 as a phone since Verizon does assign it a phone number.

    The phone number is for the line of service only. There isn't a dialer application nor is there a CDMA radio in it for voice calls.

  • Can you set the value of a div from a select statment?

    Hi all
    I have a div that is used as Tool tips for a cell in a table, is there an easy way to set the text in that div to the result of a select statement?
    Appreciate the Help
    LT

    select ename, '<div '||style||'>'||htf.escape_sc(description)||'</div>' description
    from some_table
    was this what your asking. You need to not escape special characters so the div tag acts as HTML in your report. The data is escaped using a PL/SQL function.
    Is this what your asking?
    Mike

  • Why can't you make the bookmark toolbar visible by default?????

    I went to organize my bookmarks and there is no toolbar. Now, you say it is hidden by default. That's crazy. Anyway, I can't follow the instructions. There is no Firefox button to click. There is no "options" option anywhere.
    I can't even set my default options for applications, or the Internet. That's gone too. Will you please ;make these helpful tools VISABLE BY DEFAULT! If not, why not?

    Thank you very much, Car-el. If others had told me this, the problem would have been solved three days ago! However, I wanted to rename a folder, and I don't see that this is possible. I would think that after one goes to the "Show All Bookmarks" one could change the name in the "folder name" text box and it would work, or right click on the actual folder one wants to rename and the pull down would have that option. Not so for either here. So, my problem is still not solved. Oh, well.

  • How do you set the value of an enumeratio​n programati​cally

    I would like to be able to select (programatically) the value of an enumeration.  I don't seem to be able to find any reference to how to do that.
    Thanks.
    Solved!
    Go to Solution.

    True, True.  The original post wanted to know how to programmatically "select" the enum value.  To me, that means to either force the enum to display another value, or retrieve the current value.   I thought Ben was referring to the fact that you can't programmatically set or initiate new values into an enum.  Which as he said, can only be done with a Ring.
    "In your example you're not "getting" the value of the enum. You're converting it to a string. That's a different operation."
    I showed two ways to get the value,  one gets the current string value associated with the numeric value, and the other gets the current numeric value.  i went further in the attached vi, by demonstrating how to change the current (displayed) value of the enum by using a string.  (IFF you already know the string values in the enum.)   
    In my program, i use a typedef cluster with an enum in it.  At runtime, i need to "select" the active enum value based on which operation i'm performing.  I know from elsewhere in the program what operation i need, but it's string, and there's no easy way to change the value of an enum with a string, except with the backdoor methods i showed.  
    I wish my cohort woulda used a ring.  ;-)

  • Why can't you change the .html/.htm filetype icons for Firefox?

    **Before you read this question: NOTICE I am talking about Firefox Icons on Windows, NOT ON FIREFOX BOOKMARKS/PROGRAM!!!!! Read the question then please, please visit the link so you have a better understanding of what I'm asking with this question!!!!**
    I've been trying to change the FileType Icons for the Firefox Documents for weeks now and there's no solution that I can see. I tried using Filetypes Manager to change the .html/.htm filetypes icons with no luck. Why does Firefox force this change on users when most users that use Firefox do so because of it's ability to be customizable? Even Microsoft Word .doc file icons allow you to change them! Microsoft!!! Why is Firefox forcing everyone to use their ugly filetype icons? &____& I've yet to see this issue not only addressed but solved. Why does Firefox ignore this issue? I'd like my computer's icons to all be top-notch, and Firefox is preventing me from making my weeks of hard work go to naught. Please, please address this issue... if anything, tell your users why your program is forcing the icons on them in the first place when monopolies like Microsoft allow their users to customize program filetype icons.
    If this cannot have a fix, why can't it be a new feature/addition to the newest versions of Firefox?
    Edit: And because people are starting to get 'confused' I've included a screen shot of what I'm talking about because, for the love of god, people, I'm *not* talking about using favicons and bookmarks!
    http://i28.photobucket.com/albums/c231/arcanetheorem/example.png

    The only thing I changed about the question was to add an image and to try and make it more understandable since everyone assumed I was talking about Favicons/Bookmark Icons....
    As for it being a Windows 7 issue and not a Firefox one... if it were just a Windows 7 issue I wouldn't be able to change other application icons or filetype icons on the Windows platform using FileTypes Manager. Firefox, from what I've been able to gather, is not one that can be changed. If I change the filetype icons for Word Documents any other extension (like .mp3/.mp4/.avi/.mkv), I get the changed icon I wanted. However, when you try to change the Firefox .html/.htm filetype extension icons, it doesn't work. Have you tried going through changing your icon filetypes using FileTypes Manager to see this issue? If it were a Windows or FileType Manager issue, then I'd have trouble changing other icons on that platform, no? So what I'm asking with my question is why this is. Why, if you use FileTypes Manager to change Windows7 icons, is Firefox's icons the only ones that won't be changed? Doesn't this fall under Firefox's problem if their icons are under the 'can't be changed' category under Windows? And using shortcut icons is no good for me. When I browse a folder of .html files, I want to see the icons I changed it to, not make a shortcut to every .html file I have just to have a better-looking Visual Style. Defeats the purpose, doesn't it? As for clicking on Properties to change it... Windows 7 doesn't allow this feature anymore, which is why I've been using FileType Manager to change all filetype extension icons.
    Hope that helps clear things up a bit, though I have a feeling I'm just confusing everyone more with what is a simple question/problem....

  • Why can't I set the page size in centimeters?

    Am I missing something?
    In Preferences it allows me to use centimeters (I wish there were millimeters), but when I try to change the page size I can only use inches.

    Bryan Kennedy wrote:
    Am I missing something?
    In Preferences it allows me to use centimeters (I wish there were millimeters), but when I try to change the page size I can only use inches.
    You missed the fact that the print dialog aren't belonging to Pages but to the operating system.
    So, it's unaware of the unit setting done in the application.
    On my French system, Pages is set to use points as units for the rulers but the Print Dialog is using centimeters.
    As far as I know, you may force the system to use centimeters.
    With 10.4.11 we do that in the System Preference Pane entitled International. I forgot its new name.
    Yvan KOENIG (VALLAURIS, France) samedi 3 avril 2010 22:57:53

  • Why can't i detect the value of the first column ??

    I need to retreive a list of values from the database.
    But everytime i can only retreive the values from the second rows onwards.
    String sQuery = "SELECT * FROM XTABLE WHERE XGROUP = '" + sGroup + "'";
    resultSet rs = stmt.executeQuery (sQuery);
    while (rs.next())
    sValue = rs.getString (config.sRecpMobile);
    there is supposed to be three columns that matches the query but only two are returned.
    Can anyone help me ?
    Thank you in advance.

    1. right after String sQuery = "....."; use the
    System.out.println(sQuery);
    2. cut and paste the query string that was output to the console.
    3. paste it into SQL*Plus or whatever you database utility program is, and run it.
    4. These results won't lie.
    Probably...
    5. You will realize the error in your SQL. The query you are sending to the database is actually correct, but not what you thought. You will slap yourself in the face in disgust, fix the query and continue programming...and pretend it wasn't your fault! :>)
    Jamie

  • When firefox crashes from a memory leak why can't you display the offending tab? Enhancement: a task manager like tab manager showing usage per tab / extension.

    I typically keep many windows with several tabs open. It is possible that this causes more crashes since the number of pages multiplies any effect most users with less pages/tabs would experience. I have been having problems with Firefox crashing Using the windows task manager I have looked into this issue monitoring lots of variables. Bottom line the crash is caused by increasing memory usage possibly caused by the flash add on which is doing many IO reads on at least one offending page/tab. Could some sites be using flash to read from my disk without permission and there is a memory leak in either flash of the code the sites uses? I have searched the web for a task manager like add-on for Firefox tabs that would allow me to determine the offending page/tab/add-on/extension. It seems like a great idea which has not been implemented. Since I am a developer I would be happy to implement, but would like some guidance since my knowledge of your product is only at the user level.

    There is currently about:memory page which is being actively developed. A "task manager"of sorts is also in the works AFAIK. If you want to help out, your best bet is to find the applicable bug in Bugzilla. If you have the coding skills I can help get you in touch with a mentor - just let me know.

  • Why can't I get the value of "checkedState" in ScriptUI?

    I found I can't get checkedState's value recently, and anybody can help me?
    The snippet script is following:
    #target "InDesign-8.0"
    main();
    function main(){
        myInterFace();
        myTeardown();
    function myInterFace(){
        //<fragment>
        var myDialog = app.dialogs.add({name:"Testing", canCancel:true});
        with(myDialog){
            //Add a dialog column.
            with(dialogColumns.add()){
                with(checkboxControls.add()){
                    staticLabel = "Facing Pages";
                    checkedState = true;
                    minWidth = 140;
      if(myDialog.show() == true){
            var mycheckboxControl = app.dialogs.item(0).dialogColumns.item(0).checkboxControls.item(0);
            var pageMarginSetting = new Array;
            pageMarginSetting.push(mycheckboxControl.checkedState);
            alert("testing");
            formattingTemplate(pageMarginSetting);
            myDialog.destroy();
      else{
      myDialog.destroy()
    function formattingTemplate(pageMarginSetting){
        var myFileNameString = "/C_Test_Template.indd"
        var myDoc = app.documents.add({name:myFileNameString});
        with(myDoc.documentPreferences){
            pageHeight = 280;
            pageWidth = 210;
            pageOrientation = PageOrientation.portrait;
            facingPages = pageMarginSetting[0];
            startPageNumber = 1;
        myDoc.save(File(Folder.desktop + myFileNameString));
    function myTeardown(){

    Try declaring the checkbox as a variable up in the dialog construction something like this:
    //====================//
    #target "InDesign-8.0"
    main();
    function main(){
        myInterFace();
    function myInterFace(){
        var myDialog = app.dialogs.add({name:"Testing", canCancel:true});
        with(myDialog){
            //Add a dialog column.
            with(dialogColumns.add()){
                //checkbox as variable
                var myFPCheckbox =checkboxControls.add({staticLabel:"Facing Pages", checkedState:true, minWidth: 140})
                with(myFPCheckbox){
           if(myDialog.show() == true){
                var pageMarginSetting = new Array;
                pageMarginSetting.push(myFPCheckbox.checkedState);
                alert("testing checkbox result=  "+myFPCheckbox.checkedState);
                myDialog.destroy();
      else{
                myDialog.destroy()

  • Why can't you change the font on apple devices?

    why cant you change font on iphone? i hate the font that is on apple devices!!

    Because Apple has not made that a feature of the phone. They have never stated why. However, Apple has a long history of discouraging user customization so it's not really a great suprise to anyone who's used Apple products for any length of time.
    Submit your feedback to Apple here:
    http://www.apple.com/feedback

Maybe you are looking for