fiber


Can a thread run another fiber when the running fiber is in blocked


As far as I see,a thread can run another fiber when the running fiber is in blocked.But it is not the case.I create 100 fibers which will search solr.The result I find is all the fibers is executed in order.Another fiber can execute only if the previous one is finished just like a thread.This is my code.
import co.paralleluniverse.fibers.Fiber;
import co.paralleluniverse.fibers.FiberForkJoinScheduler;
import co.paralleluniverse.fibers.FiberScheduler;
import co.paralleluniverse.fibers.SuspendExecution;
public class FilterThreadTest {
static FiberForkJoinScheduler fiberForkJoinScheduler = new FiberForkJoinScheduler("fork-join-schedule", 1);
static SolrService solrService = new SolrService();
public static void main(String[] args) {
solrService.init();
for (int i = 0; i < 100; i++) {
new CountFiber(fiberForkJoinScheduler, i, solrService).start();
}
try {
Thread.sleep(10000000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
class CountFiber extends Fiber<Void> {
/**
*
*/
private static final long serialVersionUID = 1L;
private int count;
private SolrService solrService;
public CountFiber(FiberScheduler scheduler, int count, SolrService solrService) {
super(scheduler);
// TODO Auto-generated constructor stub
this.count = count;
this.solrService = solrService;
}
#Override
public Void run() throws SuspendExecution, InterruptedException {
System.out.println(count + " fiber is starting!");
solrService.search();
System.out.println(count + " fiber is ended!");
return null;
}
}
Did I misunderstand fiber?
Fibers will yield execution to other non-blocked fibers only when they perform fiber-blocking calls, not thread-blocking ones and Quasar doesn't automatically transform thread-blocking calls into fiber-blocking ones so you need to write (small, usually) integrations for pre-existing tools that don't know about Quasar.
The concurrent programming libraries provided by Quasar (Go-like channels, Erlang-like actors, dataflow programming, reactive streams and the java.util.concurrent port) support both fiber-blocking (when called from fibers) and thread-blocking (when called from threads); the same is true for Comsat integrations that cover many tools but, as of today, not Solr. Did you build a Solr integration yourself or is solrService.search() only thread-blocking?
For more information about integrating tools with Quasar (it's usually quite easy) see for example this blog post.

Related Links

Can a thread run another fiber when the running fiber is in blocked
Quasar Parallel Universe examples
In reference to fibers, what is user space?
Do fibers have priorities?

Categories

HOME
elasticsearch
knockout.js
svn
jms
selenium-builder
writefile
nsview
plpgsql
impala
specifications
vimeo
smooks
createjs
google-awareness
rpmbuild
scala-ide
nose
libgit2
akka-persistence
altium-designer
perfino
exchange-server-2010
react-dnd
morris.js
spreadsheetgear
crud
background-color
list-comprehension
fatfs
copy-protection
envoy
progid
apptentive
directfb
landscape
cordys-opentext
installanywhere
eclipse-gmf
mv
distributed-caching
spooler
expandablelistview
sonarqube5.2
iptv
skip-lists
word-2007
sesame
controllers
system.net.mail
seccomp
dojo-build
wicked-pdf
odp.net-managed
as3-api
currency-exchange-rates
openmrs
cryptojs
apache-commons-digester
screen-orientation
auto-generate
gitlab-omnibus
featuretoggle
apple
espresso
angular-amd
unidata
tree-structure
kotlin-android-extensions
shell-extensions
mathematical-expressions
tidyr
ssmtp
mutators
fasterxml
symja
vs-unit-testing-framework
flurry-analytics
global-scope
libgcc
lumia-imaging-sdk
siena
forceclose
thruway
principalcontext
autonumber
progress-db
infinite
grails-2.3
axacropdf
web-frameworks
arel
towers-of-hanoi
pcspim
trialware
startupscript
simile
grails-validation
bll
android-input-method
resharper-5.0
spring-modules
powergui
inversion
autobench
account-management

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App