This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.io.File; | |
| import java.io.FileOutputStream; | |
| import java.io.IOException; | |
| import java.nio.channels.FileLock; | |
| // The class demonstrates how to get an exclusive file lock that prevents other threads and processes / JVMs from | |
| // obtaining a lock on the same file. To do this, you need to synchronize a block on a file and acquire FileLock. See | |
| // comments below for more details. Run this class in multiple JVMs and see each thread of each JVM acquires a lock in | |
| // an orderly fasion. | |
| public class FileLocking extends Thread |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #define __ASSERT_USE_STDERR | |
| #include <assert.h> | |
| // Pin 13 has an LED connected on most Arduino boards. | |
| // give it a name: | |
| int led = 13; | |
| // the setup routine runs once when you press reset: | |
| void setup() { |
NewerOlder