About doing something periodically

I have posted the topic in core gui api_java applet development i didn't want to post it again here, but the topic I posted is not visited as much as this one.
post:
I have a class which is very long so I will summarize the problem.I have an applet that implements runnable, and in the void run method it calls a thread and shifts my applet. and now I want to shift this system periodically but when I tried to do this in run method, threads are called at the same time and it becomes a problem. it doesn't work properly. I want to shift the system every 1 second for example. and system shifts in 900 milliseconds. could you tell me a way or suggest me a tutorial about first part of this: shifting system every 1 second by a time class or method or whatever.

I have a 2d mave and I have a point in thre middle, shifting means is to go one side here,point stays constant ant the maze shifts near it. now I want to shift this system periodically, for example every 1 second, however the shifting process for one side uses a thread and it takes 900 miliseconds to complete it. ok here is my run method;public void run() {
        Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
        boolean checkd = false;
        boolean checku = false;
        boolean checkl = false;
        boolean checkr = false;
        while (true) {
            try {
                t.sleep(1);
                if (go) {   // go is coming from a button and when it is pressed it lets the point move periodically
                    t.sleep(1000);  ////HERE I NEED AN ALTERNATIVE
                    release();  // release method is at the end of post
                if (dwn < 30) {
                    ydirec = 0;
                    xdirec = 2;
                    t.sleep(30);
                    j--;
                    dwn++;
                    repaint();
                    if (dwn == 30) {
                        System.out.println("came 30th dwn");
                        checkd = true;
                if (up < 30) {
                    ydirec = 1;
                    xdirec = 2;
                    t.sleep(30);
                    j++;
                    up++;
                    repaint();
                    if (up == 30) {
                        System.out.println("came 30th up");
                        checku = true;
                if (checkd) {
                    j = 5;
                    a.movedown();
                    wh = a.getwh();
                    wv = a.getwv();
                    checkd = false;
                    System.out.println("changed arraysfordwn");
                if (checku) {
                    j = 5;
                    a.moveup();
                    wh = a.getwh();
                    wv = a.getwv();
                    checku = false;
                    System.out.println("changed arraysforup");
                if (right < 30) {
                    ydirec = 2;
                    xdirec = 1;
                    t.sleep(30);
                    i--;
                    right++;
                    repaint();
                    if (right == 30) {
                        checkr = true;
                if (left < 30) {
                    ydirec = 2;
                    xdirec = 0;
                    t.sleep(30);
                    i++;
                    left++;
                    repaint();
                    if (left == 30) {
                        checkl = true;
                if (checkr) {
                    i = 5;
                    a.moveright();
                    wh = a.getwh();
                    wv = a.getwv();
                    checkr = false;
                if (checkl) {
                    i = 5;
                    a.moveleft();
                    wh = a.getwh();
                    wv = a.getwv();
                    checkl = false;
            } catch (Exception e) {
        }and the release method is :
public void release() {
        double d = Math.random();
        if (d <= 0.25) {
            //d <= 0.25
            if (((Boolean) (checkwall().get(0))) == false) {// whatever written inside is not important,it is a boolean coming from somewhere
                up = 0;   //activates the if(up<30) condition in run and system shifts
            d = 1.0;
        } else if (d <= 0.5 && d > 0.25) {
            if (((Boolean) (checkwall().get(1))) == false) {
                dwn = 0;
            d = 1.0;
        } else if (d <= 0.75 && d > 0.5) {
            if (((Boolean) (checkwall().get(3))) == false) {
                right = 0;
            d = 1.0;
        } else if (d < 1.0 && d > 0.75) {
            if (((Boolean) (checkwall().get(2))) == false) {
                left = 0;
            d = 1.0;
    }Edited by: dogukan on Apr 1, 2008 9:39 PM

Similar Messages

  • Why aren't apple doing something to sort out the facetime app for mac

    Why aren't apple doing something to sort this out, there is obviously something wrong as so many people seem to be having the same or very similar problems, I was about to buy the facetime app for my mac but not sure I should now
    Come on apple, no use sticking your head in the sand, get it sorted.
    After all, you are quite happy to take peoples money for your app, the least you can do is to ensure it works.

    Backing up and restoring is not the same as downgrading.
    Apple have stopped signing 5.1.1 which is why you can't downgrade.

  • IPhoto won't delete the photos from my iphone once I have imported them and indicated to delete the photos from my phone.  Am I doing something wrong?

    I have imported several hundred photos from my iPhoen 5C into iPhoto library.  I selected yes to delete them from my iPhone but the photos remain on the phone.  Am i doing something wrong.  I don't want to pay apple a fee to get this answered via their support system.  This should be straight forward, shouldn't it?  Thanks.

    Are you asking about iCloud Photo Library (Beta) as described in: iCloud Photo Library beta FAQ - Apple Support   ?
    In that case you will still see all photos on your iPhone, even after uploading the Photos to the iCloud Photo Library.  The photos on your iPhone may be light-weight optimized previews, if you have the setting
    Settings > iCloud > Photos or Settings > Photos & Camera > iCloud Photo Library > Optimize [device] Storage   enabled.
    But as long as you have enough free storage, will the your iPhone keep the full resolution versions of the photos you access most frequently.

  • I add apps to my toolbar for the websites I use most frequently, or to remember one that I do not use as ofter. These apps disappear on what used to be a monthly basis, and now more frequently. Am I doing something to cause this?

    I love the feature to pin as app tab on my toolbar. When I first began using this feature, after about a month the toolbar would drop all my apps. I would have to re-add as I used the websites again. Some of my sites I would add because I didn't use them enough to remember them all the time and this was a big help from having to search for a sight all over again. Am I doing something to cause these apps to be dropped? It seems to be happening more frequently now, like every couple weeks. It is annoying to have to keep going back and pinning these sites as app all over again.

    Tks Turingtest2,
    That gives me something to think about.
    Let me tell you a little more of the puzzle which I should have added originally!
    I have about 60 podcasts.  So I want to group those podcasts that I need to download everyday into one "collection" - then at the begiining of the day, I look at the "Every Day" collection of podcasts and then manually down load them.  This way I do not have to look at the other 40 podcasts which are weekly or Monthly podcasts.
    Your script idea will help me with another problem I have (tks!) but I dont think it wil help with this problem!
    I really want to assign something at the "header" level - ie the actual podcast name, rather than the individual daily or weekly or monthly podcasts which is how your script works.
    I think I have found a possible fix by assigning a code (ie "weekly") in the "Composer" field of the podcast and then showing "Composer" in the column browser and then selecting all the weekly ones etc etc.
    I will test this!
    Tks again!

  • Do you know how to record yourself doing something?

    Hello, do you know how to record yourself doing something, like teaching a craft, or ranting about something so it can be uploaded to a video provider... from an iMac? Thanks if so!
    <Re-Titled By Host>

    Thank you, but I mean by video, like a full tutorial. Quicktime does an ok version, but blurs at high speeds, (like if you're jumping or boxing etc) so I'd like to know what good apps record a decent VIDEO (not photos) from the iMac camera. The camera can remain in one place, the instructor has a stable mark to work within so they don't go out of screen,  but yes, fast movement just has tracers. It might have been the lower light though. Bright light would help this issue I bet...
    I know from the plethora of well done youtube videos, it's possible. Just not sure what apps may be best.
    Thanks again!

  • Im using intel macbook pro 13" and since I'm using the new OSX Lion, the keyboard backlit won't turn off and it's eating up my precious battery. Im always mobile so this is very important. Apple doing something to fix this bug immediately?

    Im using intel macbook pro 13" and since I'm using the new OSX Lion, the keyboard backlit won't turn off and it's eating up my precious battery. Im always mobile so this is very important. Apple doing something to fix this bug immediately?

    multiplryan wrote:
    To be totally honest, about 3 weeks prior I spilled some milk from cereal on the desk and a little bit got onto the battery.
    I don't think you have a case.
    You can replace the logic board yourself if you are a DIY'er and save some money.

  • Maven dependency mgmt: am I doing something wrong?

    (title shortened to simply not make it too long, not because I am l33t).
    I have a little frustration that only makes me wonder if I am doing something wrong. My general opinion about maven is that it is a great tool that can save a lot of effort managing builds. However, I sometimes find myself traversing down dependency management hell. The source of my problems: transitive dependencies.
    Is it me, or is the maven repository tree polluted? Sometimes I have no other option (that I know of) than adding manual exclusions to my parent poms to filter out transitive dependencies I really do not need, and in some cases even cause conflicts. Now I must say, most of these problems stem from JBoss endorsed projects such as Seam and JBPM.
    If for example I add JBPM 3.3.2 to my application I get Jackrabbit, Lucene and whatever else for "free" with it - I exclude them to keep my dependency tree clean because during runtime these dependencies really are not needed.
    Worse is when I want to use JBoss Seam 2.1.2 (on JBoss 4.2.3, unfortunately I cannot go to a newer JBoss yet) - to be able to do this I must include a dependency org.jboss.el/jboss-el to the project and war, otherwise a single util class cannot be found (grrr). But this dependency transitively adds javax.el / el-api - at compile scope! If this is let slip through and a war is deployed with this dependency present, a classpath isolated environment will give classloader clashes with the classes that the JBoss server itself provides. So I add an exclusion...
    These were just isolated examples and certainly not the only ones I encountered so far. Does anybody else experience these kind of issues? And is there perhaps something obliviously obvious that I am failing to do which would rid me of the need to add manual exclusions? Or am I correct in stating that the repository really is this polluted?

    I've seen that effect, but luckily not to a degree where it got a huge problem. Simply write the necessary excludes when you see such a case and go on. It wasn't necessary too often yet.
    The problem seems to stem from the fact that many Maven artifacts are simply "project X". That means that each and every feature that project X provides is bundled in a single jar which draws in each and every dependency that project X has anywhere.
    The smarter (or at least more maven-friendly) approach would have been to split project X in "project X - core functionality", "project X - lucene search support", "project X - frobnicator" and provide a "project X - everything" module that pulls in all there is for the project.
    This way we could pick only those modules that we need in our dependency and therefore also get only those transitive dependencies that we really need.
    Unfortunately only a few projects have that kind of architecture, so we'll have to live with the excludes for a while.

  • Presets - am I doing something wrong?

    Wonder if someone can quickly tell me what I'm doing wrong here.
    I'm trying to add a preset which I can drop onto other clips quickly and easily.
    I take a clip and apply the effect I want to it. I then choose that effect in the Effects Control Window and try and "Save Preset" but it is greyed out. Am I missing an obvious step here?????

    Hi Tom - thanks for your reply - however, I think you've just verified that it simply isn't working for me as that is exactly what I have done. I noticed it was greyed out and thought I would do all the changes in the Effects Control panel itself but even when I create it from scratch in there or change an already created effect then it still stays greyed out for me. It is the Time Remapping I'm trying to do here as well.
    The problem with the Copy and Paste attribute is that doesn't work properly either!!!! I've created a 50% speed remap - but when I copy it and paste attribute - although it says it's 50% it clearly isn't and sometimes is only about 10% longer than the original clip. It appears to be another bug in the software although I was hoping I was doing something wrong!!
    Thanks for your reply anyway though.

  • Surprisingly jaggy output - am I doing something wrong?

    Look at these examples:
    http://www.reesweb.com/samples/jaggy/
    The first is a screencap of the fullscreen view in Aperture. The image is a 1728x1153 crop from an 8mp original. Not a great picture, but it looks OK.
    The second is that same version exported as a full-quality jpeg set to "fit within 1280 x 1280." Jaggy!
    What's going on here? The results are so bad that I must be doing something wrong. All I'm doing is selecting the 1728 version, choosing export version, and selecting the export option (JPEG - fit within 1280 x 1280).
    The third image, btw, was produced by exporting the cropped original as PSD and doing the resize/jpeg encoding in Photoshop. Looks much better.
    And thoughts about what's going on here?
    Will
    Dual Core 2.3GHz PowerMac G5, 2GB RAM, GeForce 6600   Mac OS X (10.4.6)   Canon Digital Rebel XT, Edirol UA-5

    OK, it looks like the jagginess only happens when I set the export DPI to 300 with my particular original and export sizes. When I set it to 72, the exported version looks fine and is not jaggy.
    I see the same behavior for jpgs, tiffs, and psd.
    I also tried with some small sizes and found something else. When you export to "fit within 320 x 320" and you choose 72 DPI, the image gets sharpened. If you choose 300 DPI the image is not sharpened. Strange. Maybe there's a reason for that I don't get.
    This is what I'm seeing for all export types (jpgs, tiffs, etc) starting with a 1728 x 1153 image:
    320 x 320, 72 DPI: sharpened nicely
    320 x 320, 300 DPI: not sharpened, soft but no jaggies
    640 x 640, 72 DPI: sharpened nicely
    640 x 640, 300 DPI: not sharpened, soft but no jaggies
    800 x 800, 72 DPI: sharpened nicely
    800 x 800, 300 DPI: not sharpened, soft but no jaggies
    1024 x 1024, 72 DPI: sharpened nicely
    1024 x 1024, 300 DPI: sharpened but with nasty jaggies
    1280 x 1280, 72 DPI: sharpened nicely
    1280 x 1280, 300 DPI: sharpened but with nasty jaggies
    Original Size, 72 DPI: It doesn't look sharpened at all, no jaggies
    Original Size, 300 DPI: It doesn't look sharpened at all, no jaggies
    50% Size, 72 DPI: sharpened nicely
    50% Size, 300 DPI: not sharpened, soft but no jaggies
    25% Size, 72 DPI: sharpened nicely
    25% Size, 300 DPI: not sharpened, soft but no jaggies
    And more data, but this time starting with a 3456 x 2298 (digital rebel default) image:
    1280 x 1280, 72 DPI: sharpened nicely (some images a bit too much)
    1280 x 1280, 300 DPI: not sharpened, soft but no jaggies
    So it looks like the combination of using 300 DPI and certain original and export sizes can result in some nastiness.
    It is also interesting to note that in most situations, using 300 DPI turns off or greatly reduces the automatic export sharpening. Juicy info for those looking for ways to circumvent that feature.
    Will
    Dual Core 2.3GHz PowerMac G5, 2GB RAM, GeForce 6600   Mac OS X (10.4.6)   Canon Digital Rebel XT, Edirol UA-5

  • Why does it take so long to upload? Am I doing something wrong?

    At the moment it takes a few hours(!) to upload about ten pages on one site. Just pictures. iPhoto used to publish within five minutes. Why does it take so long? Am I doing something wrong, like having it on a weird setting? It looks beautiful, but not very impressed with iWeb functionality as of yet.

    don't know if i can downgrade the file sizes, am just selecting the photos in iphoto and then clicking iweb so it should do it automatically. it shouldn't take hours though should it? the site address is web.mac.com/adilamin/iWeb but there is no problem with accessing the site and loading the pics, its just the uploading from iWeb.

  • I sync with outlook'07, the itunes bar does something but it never works!

    hi guys,
    I've posted something a little similar to this in the music forum but talked more about my ringtones, so thought it'd be better to stick this one in here...
    I exported all my contacts onto my computer from my old k800i, then imported them into contacts on outlook.
    Then I synced my iphone to outlook through itunes and it appears to be doing something on the itunes bar only for me to open my phone when it's done and the contact list is empty.
    It's synced the calender and itunes music though.

    Have you looked at the previous discussions listed on the right side of this page under the heading "More Like This"?
    Also
    Advanced troubleshooting for Sync Services on Windows with Microsoft Outlook 2003, Outlook 2007, or Outlook 2010

  • My Camcorder shoots 24fps and I set my iMovie project at 24fps.  But when I add the clip, it's saying that the clip is at 30fps?  Am I doing something wrong?

    But when I add the clip, it's saying that the clip is at 30fps?  Am I doing something wrong?

    Let me tell you this: don't worry about it.
    No one is able to tell very easily if the video is in 24 or 30 fps. You can only see the difference between, like, 14 and 24 fps. Just dismiss it and move on. It's all fine.
    (the only time that I personally need to make sure my camera is shooting at it's highest fps, is when I will be putting the vidoe into slow motion.)

  • DVD's don't always play...am I doing something wrong?

    Hey, sorry if this has been posted several times before...I have dvds that play fine on higher end dvd players, but won't on "off" brand players...I'm using FCP4 and DVDStudio Pro3. I use compressor from FC and export as mpeg 2 with a 2hour setting. I then imput the compressor Audio/video files into DVD SP, build and format the dvd. I don't have any problems playing on a good player, but my clients complain that they have problems on an off brand player...is this to be expected on these consumer created dvds, or am I doing something wrong? Thankyou for your input

    ok, i'm looking at compressor and don't see the audio format that has been talked about to use. The one that has been used is under the MPEG-2 120 Min high quality encode. The following is a copy and paste of the summary for each preset.
    Video Preset:
    Name: MPEG-2 120min High Quality Encode
    Description: 3.5Mbps,2-Pass VBR,4:3
    File Extension: m2v
    Video Encoder
    Format: M2V
    Width and Height: Automatic
    Pixel aspect ratio: default
    Crop: None
    Frame rate: (100% of source)
    Aspect ratio: 4:3
    Field dominance: Auto detect
    Average data rate: 3.5 (Mbps)
    2 Pass VBR enabled
    Maximum data rate: 7.5 (Mbps)
    High quality
    Best motion estimation
    Closed GOP Size: 1/2 second, Structure: IBBP
    DVD Studio Pro meta-data enabled
    Audio Preset:
    Name: DVD PCM Audio
    Description: AIFF 48Khz,16bit,Stereo
    File Extension: aiff
    Audio Encoder
    Format: QT
    Sample Rate: 48.000kHz
    Channels: 2
    Bits Per Sample: 16
    Codec Type: Uncompressed
    I looked under the different compression settings and it says the encoder is AIFF, but under the settings for it, it doesn't list AC3. My Compressor version is 1.2.1
    Also, how does all the settings look for the video...see any prolems that would explain the low end players messing up?
    Thanks again for the help...its appreciated!

  • Trying to download Lion trought App store, it downloads and it asks for account login and it installs again it never shows installed it always shows installing. this is the third time it's installing. Am I doing something wrong?

    Been trying to download Lion from the App Store.  It saks for login, I login in and it starts install.  After about 13 hours it finishes download then asks for login again.  After login, it starts installing again. It never shows installed.  This is the third time I am doing this.  Am I doing something wrong?

    Sorry, my bad, we have the iMac G5 10.6.8.  I just got home and the message said an error occurred and was unable to download.  Am I doing something wrong or is there something I need to do.

  • Security risk? or am i doing something wrong?

    hello all,
    i administer a snow leopard server machine to serve out files via AFP to a small company. i think i may have either discovered a security bug, or if i'm doing something wrong, if someone would be kind enough to help, i'd greatly appreciate it. here's what happening (with criticial info changed obviously):
    let's say the server has two users that login to access files, userA and userB.
    userA's password to login is boat and userB's password is train.
    either userA or userB can successfully login and gain access whether they use boat or train as their password.
    i only discovered this as userB's password is the same as userA's old password on a Tiger server we had years ago, and userA was able to successfully log in with this old password that should have been rejected. i then did a test to see if the other way work, and lo and behold yes, that's when i found out that any user can log in successfully so long as ANY user's password was being used.
    i haven't been able to test various OS flavors, but all of our client boxes run Leopard, while the server is Snow 10.6.3.
    am i doing something wrong in my user set ups? it doesn't seem like this would be an intended feature. thanks to anyone that can help.
    j

    That certainly doesn't sound right, but it's such a fundamental part of file sharing that it needs further investigation.
    First thing to check is whether guest logins are available, and whether you're actually logging in as a guest rather than a registered user when the incorrect password is used.
    The server's logs (or Server Admin) should be able to confirm this.
    While I might expect an incorrect password to reject the login, if you have guest access you're essentially saying you don't care about authentication anyway, so it might be the issue.
    The second thing to check is whether the same happens on other forms of login to the server, e.g. ssh, SMB, etc.
    That will help identify whether the problem relates to AFP or something more global on the server (e.g. there may be a local account for userA and userB that's being used rather than the Open Directory account you expect.

Maybe you are looking for