One More Time: Shared Memory

I've heard the designers of Java (Gosling, Et. Al.) are against supporting the concept of shared memory natively.
However, have they given any more thought to simple native shared memory support?
I know there are several "C" libraries with JNI that provide shared memory for Java. I just really would like native support.

I like it. Although it does leave a file around that I have to delete.
Any issues with this method?
BTW, here is the code from the reference:
import java.io.*;
import java.nio.*;
import java.nio.channels.*;
import java.util.*;
class TestShared1 {
public static void main(String[] args) throws Exception {
Random r = new Random();
//-- Opening the file
RandomAccessFile raf = new RandomAccessFile ("myshared", "rw");
FileChannel fc = raf.getChannel();
//-- Getting the memory-mapped byte buffer
MappedByteBuffer mbb = fc.map (FileChannel.MapMode.READ_WRITE, 0, 1024);
//-- Writing a random integer in the first 4 positions of the memory
//-- every second
for (int i = 0; i < 1000; ++i) {
try { Thread.sleep(1000); } catch (InterruptedException ex) {}
int x = r.nextInt();
mbb.putInt(0, x);
System.out.println ("Written to the shared memory: " + x);
fc.close();
raf.close();
and
import java.io.*;
import java.nio.*;
import java.nio.channels.*;
import java.util.*;
class TestShared2 {
public static void main(String[] args) throws Exception {
Random r = new Random();
//-- Opening the file
RandomAccessFile raf = new RandomAccessFile ("myshared", "rw");
FileChannel fc = raf.getChannel();
//-- Getting the memory-mapped byte buffer
MappedByteBuffer mbb = fc.map (FileChannel.MapMode.READ_WRITE, 0, 1024);
//-- Printing the integer that is in the first 4 positions of the memory
//-- every second
for (int i = 0; i < 1000; ++i) {
try { Thread.sleep(1000); } catch (InterruptedException ex) {}
int x = mbb.getInt(0);
System.out.println ("Read from the shared memory: " + x);
fc.close();
raf.close();
}

Similar Messages

  • How can i Delete all foto from my iphone and after some time get them one more time on it but not as a new album :)?

    How can i Delete all foto from my iphone and after some time get them one more time on it but not as a new album, i want them in the camera roll ?

    How can I delete EVERY THING off my Mac and have it like new?
    Boot from the software install DVD and do an "erase and install" when prompted.

  • [svn] 1594: Update the warning message when outbound throttle policy of REPLACE is used one more time .

    Revision: 1594
    Author: [email protected]
    Date: 2008-05-07 11:10:27 -0700 (Wed, 07 May 2008)
    Log Message:
    Update the warning message when outbound throttle policy of REPLACE is used one more time. Now the warning says this. . .
    Throttle outbound policy 'REPLACE' found on message destination 'MESSAGE_DESTINATION'. The 'REPLACE' throttle outbound policy has been deprecated. Please remove it from your configuration file.
    Modified Paths:
    blazeds/branches/3.0.x/modules/core/src/java/flex/messaging/MessageDestination.java

    hamish72 wrote:
    You can still download as much as you can only a lot slower during peak times off peak will not be restricted.
    Thanks for this explanation. I had taken it that it was at all times.
    As I said in the first place it will be great if they throttle me to 1Mb at peak times as it will be better half the time than I am getting anyway!!!!!!!!!
    hamish72 wrote:
    Have you chased up why your line is so bad, long way from exchange and so on
    Posting your router stats may get advice from someone
    enter for homehub for other routers will differ
    192.168.1.254 in browser click A to Z top right
    then ADSL enter pas and click MORE DETAIL
    POST RESULTS
    Also post results of test at ( best done from master test socket)
    http://speedtester.bt.com/
    Connection Information
    Line state
    Connected
    Connection time
    6 days, 11:57:55
    Downstream
    5,760 Kbps
    Upstream
    448 Kbps
    ADSL Settings
    VPI/VCI
    0/38
    Type
    PPPoA
    Modulation
    G.992.1 Annex A
    Latency type
    Interleaved
    Noise margin (Down/Up)
    5.7 dB / 21.0 dB
    Line attenuation (Down/Up)
    44.6 dB / 24.0 dB
    Output power (Down/Up)
    8.9 dBm / 1.6 dBm
    Loss of Framing (Local/Remote)
    0 / 0
    Loss of Signal (Local/Remote)
    0 / 0
    Loss of Power (Local/Remote)
    0 / 0
    FEC Errors (Down/Up)
    25279 / 134
    CRC Errors (Down/Up)
    700 / 196
    HEC Errors (Down/Up)
    5427 / 142
    Error Seconds (Local/Remote)
    477 / 102

  • How to download one more time the purchased content?

    I purchased yesterday the OST of Fast Five, and unexpectedly I deleted it from my Mac. How to access it one more time?

    If you are in a country where you can re-download music, and if it is still in the store, then it should show under the Purchased link under Quicklinks on the right-hand side of the iTunes store home page on your computer's iTunes for re-downloading. If you aren't in a country where music can currently be re-downloaded then you will need to try contacting iTunes Support and see if they will grant you a re-download : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page, then Purchases, Billing & Redemption

  • I have to pay one more time!

    Hi!
    I have bought the album called "Disc-Overy" from Tinie Tempah. I did reset my iPhone and set it up as a new iPhone. I also synced with another iTunes library. Now iTunes ask me to pay for the album again! I aldo bought the ringtone called "Levels" of Avicii and I have to pay for that one more time too!
    And when it comes to app. I downloaded iCopter from appstore. I bought the pro version in-app and when i try to do the same again with this newly setup iPhone I also have to pay for this one more time! Please help me!

    I've had the same problem with the albums when switching iPhones.
    Usually when you click purchase in the app- or itunes store it will start the download but will then give you the message: "You've already bought this item, do you want to download it again?". In that case you won't be charged twice, but in my expirience that won't show up untill you're willing to make the purchase.
    Best thing would be to just sync the new iPhone with iTunes if that already contains your purchased apps, books and music.

  • My iphone has broken and I had songs that I had purchased on there that I had not yet backed up on my computer. apparently you can download the tracks one more time free of charge does anybody know how??

    how do you re download tracks that are on a broken iphone???

    apparently you can download the tracks one more time free of charge does anybody know how??"
    Not true.  You get one and only one download.
    In some instances, itunes has allowed another download to a few.  This is not the norm.
    You can try contacting itunes support and asking for an exception, but they are under no obligation to allow.
    Hope all goes well.
    http://www.apple.com/support/itunes

  • It says I need one more gb of memory to upgrade my 2007IMAC intel to Mt lion then eventually to mavericks. can I download that memory

    It says I need one more gb of memory to upgrade my 2007IMAC intel to Mt lion then eventually to mavericks. can I download that memory

    Memory = RAM
    TheGroz wrote:
    . can I download that memory
    That is not how it works...
    Macs can be very Fussy about RAM...
    You can use these Links to check which RAM is suitable for your Mac...
    http://eshop.macsales.com/shop/apple/memory/
    http://www.crucial.com
    It is Important to get the Correct and Matching RAM
    Those sites also have videos on how to Install RAM should you need it....
    TheGroz wrote:
    It says I need one more gb of memory to upgrade my 2007IMAC intel to Mt lion then eventually to mavericks.
    Get as much RAM as your Mac can take. You will need it.

  • HT5552 Apple decline payment method for apple ID (credit card VISA) after 2 weeks of active using it. And did it one more time

    Few mothes ago I registered my Apple ID.Payment method chose credit card VISA. It allowed me to make purchases and download apps. But after 2 weeks it said that my payment method was declined and I have to register and pay 1$ once again. So I registered one more time with the same credit card, made several downloads and purchases and after 2-3 weeks the situation was the same. My payment method was declined. What is the reason?

    Kateryna Malykhina wrote:
    ... My payment method was declined. What is the reason?
    As this is a User to User forum no one here would know...
    You need to Contact iTunes Customer Service and request assistance
    Use this Link  >  Apple  Support  iTunes Store  Contact

  • HT201272 I bought PDF expert $9.99 for my ipad. When I tried to download to my iphone 5 , they tried to charge me one more time. Any solution?

    I bought PDF expert $9.99 for my ipad. When I tried to download to my iphone 5 , they tried to charge me one more time. Any solution?

    There are two separate PDF Expert versions on App Store: PDF Expert for iPad and PDF Expert for iPhone. PDF Expert for iPad differs from iPhone version and both versions are not free.

  • Big problem with my macbook pro 2009 - 3 motherboard changed at applestore Velisy and one more time it is for nothing.... ! Apple says you're not lucky?????

    3 motherboard i have changed at applestore Velisy and one more time it is for nothing.... !
    Apple says you're not lucky????? What can i do

    A sorry it 's macbook pro unibody from 2011

  • Web sharing & 403 Firbidden, one more time

    I've read, to varying degrees of understandability, various articles and help files on the 10.5 web sharing issue. I've tried & failed. I've come to the article below, which I think states clearly why web sharing does not work out of the box with 10.5.5. I want to follow the ix it offers, but, as with so many other articles, it talks a level or 2 above my expertise.
    My questions include:
    • How do you "Navigate to the Apache2 user configuration directory"? What does that mean?
    • What is "cd /private/etc/apache2/users"? Is it a file? Is it something you type in Terminal?
    • What it "tee"?
    Questions go on along these lines until the end of the article; in short, is there a how-to for Apache / Terminal beginners. The overriding question is, why hasn't Apple addressed the web sharing snag by the 10.5.5 iteration of the OS?
    FYI I am hung up on web sharing directly due to my move from Palm to iTouch as PDA. With the Palm Zire31 I was able to do light word processing, and did hundreds of paragraphs with it; also as a reader, and reads tens of thousands of articles on it. I want to do the same with the iTouch. To that end I've duly downloaded and installed BookZ and eReader, to enable me to move articles back & forth from the iTouch to my new iMac, to be blocked by the dreaded 403 error.
    After reckoning this problem I hope a 3rd party will come out with a real light WP app like that for the Palm: WordSmith.
    Here's the article-
    Configure Apache Web Sharing for user accounts in Mac OS X 10.5 Leopard:
    http://www.gigoblog.com/2007/11/08/configure-apache-web-sharing-for-user-account s-in-mac-os-x-105-leopard/
    Someone please help me.

    Leopard web sharing works just fine out of the box (well, it does for me anyway), although if you updated from Tiger rather than doing a fresh install (not really a good idea for new OS version), you may get the 403 error. Once turned on, it is as simple (?) as dropping files into your user's Sites folder.
    That article is horrible - I don't know what the heck they are doing using a utility such as tee to edit configuration files. For stuff like this, the free text editor TextWrangler works as well as shell utilities (especially for those not comfortable with them), and it can also navigate to and open those normally hidden files.
    As for Apache, it is industrial strength, so there is a lot of stuff you can do with it (don't ask me, I'm just a duffer). The default websites on your computer (as shown in the System Preferences > Sharing > Web Sharing pane) have links to the documentation on your computer, or you can wander around and find other references such as Apache DevCenter.

  • One more time - problems with fans

    I realize this is but one of hundreds or possibly thousands of cases of Mac users being plagued by fan noise problems, but to me it has been a long and extremely frustrating saga. I have been a Mac user since the very beginning, through different versions of Macs and iMacs, and this is the first time I ever refer to a Macintosh as a "piece of junk."
    I bought my iMac G5 in August 2005, a 20-inch ALS with 250 GB hard drive and 512 MB RAM. It worked perfectly until January this year, when all of sudden it shut down by itself. Freaked me out completely. Turned out to be power supply problem (EMC 2056) which Apple never informed me about.
    I brought it to a repair shop that fixed the intermittent shut-down problem. I also added 1GB memory. But then the fans started to go berserk. Before the power supply problem, I only heard the fans whenever I used a large program like Photoshop. For the most part, it was a very quiet machine. After the power supply was replaced, within minutes of turning the iMac on, I could hear the fans spinning faster and faster, stabilizing at around 4400 rpm and did not stop spinning until I put the iMac to sleep or turned it off, regardless of CPU usage or software being used.
    I checked the discussions at this forum (over 500 posts, no real answer) and did every "voodoo trick" suggested: I reset the SMU dozens of time, cleaned the inside of the iMac and around the fan area, did apple hardware test (everything was fine), monitored temperature and activity with XRG (average CPU at 160F, hard drive at 113F), cleaned out caches, tested for corrupt preferences, re-installed the original OS 10.4 (which only made the fans louder), upgraded it back to OS 10.4.9. I also removed the additional 1 GB memory, thinking it might be a bad piece. It didn't help.
    Finally, I requested fan replacement from Apple and got them. I installed them last Sunday and now the problem is even worse! Within SECONDS of turning it on, the CPU T- Dio soars to around 170F, even while the machine is still stone cold to the touch. The hard drive temperature now averages at 117F, CPU fan is never below 4000 rpm (4400 rpm 98% of the time), even at 5-8% CPU usage.
    The fans themselves are much quieter because they're brand new. But you can still hear the hums and whirs and it drives me nuts. More seriously, my iMac is now narcoleptic. If I use it too long (a few hours on a stretch) it will put itself to sleep, apparently because it thinks it is overheated. And when I use Photoshop or Illustrator, the awake time is even shorter. Depending on the outside temperature, at the most I can only use them for about an hour at a time. Two days ago we had heat wave, and even with the air conditioner running full blast in my study, the iMac kept falling asleep within minutes of using Illustrator.
    Right now I am using TextEdit and no other program is running. Uptime is 59 minutes, average CPU 9.6%. CPU T-Dio is at 168.8F, hard drive 117.5F, CPU fan at 4400 rpm. I am out of ideas and before I do something drastic to this machine, if anyone knows what's going on with my iMac (I know every case is different), please help!
    iMacG5 ECM 2056   Mac OS X (10.4.9)   20"/2.0GHz Power PC/1.5GB DDR SDRAM/250GB
    iMacG5 ECM 2056   Mac OS X (10.4.9)   20"/2.0GHz Power PC/1.5GB DDR SDRAM/250GB

    I do not have the solution... but the same problem with a nice iMac G5 purchased in July 2005.
    My Mac operated very silently untill 6 month ago;problem MAY ( I am not sure) have started when I upgraded to 10.4.10 ; even with few applications and low CPU usage (80% or more inactive), it seems that I have the following regrettable chain of events;
    ==> the CPU temperature is quite high ( 60°c to 72°c most of the time, ie 140-160 °F)
    ==> resulting in fan turning at high speed ( 2.000 for CPU and system, 2500 for HD), and changing speed all the time
    ==> resulting in a noisy computer
    I am SURE this was not the case 6 month ago, and I suspect it is linked to my upgrade to 10.4.10.
    I did all sorts of reinstall, authorization repair, SMU reset, fan clean-up with no sucess.
    iMac G5 (2005)   Mac OS X (10.4.10)   POwerbook G4 Titanium (2001)

  • I can tell the differnce when listening to "One More Time" by Daft Punk...

    ...The 356kb version when compared to a 128kb version I had. The electronic sounds sound a lot more crisper then on the other one...not to mention it doesn't make a fuzzy sound when I turn it up high on the iPod...but then again, like I said in another thread, I also compared "Smile" by Lily Allen and they sounded very much the same. I'm also using noise-cancelling headphones and a brand new audio card so it should be easy to hear the difference when played...to tell you the truth, it's better on a few songs but sound very much the same on other songs...it depends on what the song is and what type of audio equipment you have.
      Windows XP  

    If the errors are consistent across OS (ie LiveCD, Windows?)  then your motherboard is most likely on it's way out and needs replacing
    You could try removing the motherboard cell battery and doing the "classic capacitor flush" again. Leaving the battery out for a period of time generally has the same effect and in "classic" IT style fixes numerous woes... have you tried a different cable?
    If, after replacing the battery, the problem has disappeared I would still treat the hardware as suspect and have it replaced as soon as possible. These sorts of brain farts typically reappear sooner rather than later

  • CS5.5 DW - if it crashes one more time, I'm gonna strangle someone

    Good afternoon, all,
    I'm having a heck of a time with DW CS5.5 crashing EVERY TIME I edit a Spry horizontal menu bar. Other than saving every, say, 5 seconds (which I will one day be in the habit of doing if this keeps up), does anyone have any suggestions?
    Thanks,
    Peg

    You're not giving us much to go on.
    Are you getting any error messages?
    Which OS?
    How much RAM memory do you have?
    Does this happen with all sites or just this one?
    Are you working with valid HTML code?
    http://validator.w3.org/
    If you create a new, plain vanilla page and insert a spry menu and edit it, what happens?
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists 
    http://alt-web.com/
    http://twitter.com/altweb

  • Cookie Value - problem one more time

    when I set a Cookie like: response.addCookie(new Cookie("Name","hello"));
    and I try to get the value: cookie.getValue();
    I will get: hello no problem!
    But when I set a Cookie with an String identifier like:
    String str = "hello";
    response.addCookie(new Cookie("Name",str));
    and I try to get the value: cookie.getValue();
    I will get: "hello " (it's written in "")
    how can I prevent this ?????????
    when I try to compare the CookieValue with another String, I'll allways get a wrong result because of these ""

    I do not have the solution... but the same problem with a nice iMac G5 purchased in July 2005.
    My Mac operated very silently untill 6 month ago;problem MAY ( I am not sure) have started when I upgraded to 10.4.10 ; even with few applications and low CPU usage (80% or more inactive), it seems that I have the following regrettable chain of events;
    ==> the CPU temperature is quite high ( 60°c to 72°c most of the time, ie 140-160 °F)
    ==> resulting in fan turning at high speed ( 2.000 for CPU and system, 2500 for HD), and changing speed all the time
    ==> resulting in a noisy computer
    I am SURE this was not the case 6 month ago, and I suspect it is linked to my upgrade to 10.4.10.
    I did all sorts of reinstall, authorization repair, SMU reset, fan clean-up with no sucess.
    iMac G5 (2005)   Mac OS X (10.4.10)   POwerbook G4 Titanium (2001)

Maybe you are looking for

  • Changes in Library AND Finder?

    Ok so I'm new to iPhoto.. and here's my problem... when I make changes in the iPhoto library, like adjusting colour, cropping, or even duplicating pictures, no changes take place in the folder where the pictures orginially came from (in finder). Why?

  • Live streaming Advice for a Newbie

    Hello All, I have a task before me that I have not spent any time researching in the past because I never thought I would have to do it... I need some specific advice from some of you gurus out there. I need to set up a training facility in which we

  • IRecruitment - unable to open Manage My Account

    Hi, From the irecuitment Employee Site Visitor homepage, Manage My Account link shows an error as follows Error Page You have encountered an unexpected error. Please contact the System Administrator for assistance. I have a doubt it is to do with the

  • Infected file

    I ran a scan of the folder ~/Library/Mail/[email protected]/INBOX.mbox, using ClamXav (latest version, latest engine). One infected file was found, according to the Scan Summary. It is listed as: ~/Library/Mail/[email protected]/INBOX.mbox/mbox: (nul

  • Iphone music and video problem

    I'm experiencing a problem with the video and sound playing at an incredibly slow speed. problem just started. everything else works fine. Just the video streams and the ipod music.